logo资料库

Distributed Computing with Go 9781787125384.pdf

第1页 / 共327页
第2页 / 共327页
第3页 / 共327页
第4页 / 共327页
第5页 / 共327页
第6页 / 共327页
第7页 / 共327页
第8页 / 共327页
资料共327页,剩余部分请下载后查看
Title Page
Copyright and Credits
Distributed Computing with Go
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the author
About the reviewers
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Developer Environment for Go
GOROOT
GOPATH
src/
pkg/
bin/
Package management
go get
glide
go dep
Structuring a project
Working with book's code
Containers
Docker
Docker versus Virtual Machine (VM)
Understanding Docker
Testing Docker setup
Dockerfile
main.go
Testing in Go
variadic.go
variadic_test.go
Running tests in variadic_test.go
addInt.go
addInt_test.go
Running tests in addInt_test.go
nil_test.go
Running tests in nil_test.go
Summary
Understanding Goroutines
Concurrency and parallelism
Concurrency
Code overview
Serial task execution
Serial task execution with goroutines
Concurrent task execution
Parallelism
Go's runtime scheduler
Goroutine
OS thread or machine
Context or processor
Scheduling with G, M, and P
Gotchas when using goroutines
Single goroutine halting the complete program
Goroutines aren't predictable
Summary
Channels and Messages
Controlling parallelism
Distributed work without channels
Distributed work with channels
What is a channel?
Solving the cashier problem with goroutines
Channels and data communication
Messages and events
Types of channels
The unbuffered channel
The buffered channel
The unidirectional buffer
Closing channels
Multiplexing channels
Summary
The RESTful Web
HTTP and sessions
A brief history of HTTP
HTTP sessions
The REST protocol
The server and client architecture
The standard data format
Resources
Reusing the HTTP protocol
GET
POST
PUT and PATCH
DELETE
Upgradable components
Fundamentals of a REST server
A simple web server
Designing a REST API
The data format
The book resource
GET /api/books
GET /api/books/<id>
POST /api/books
PUT /api/books/<id>
DELETE /api/books/<id>
Unsuccessful requests
Design decisions
The REST server for books API
main.go
books-handler/common.go
books-handler/actions.go
books-handler/handler.go
How to make REST calls
cURL
GET
DELETE
PUT
POST
Postman
net/http
Summary
Introducing Goophr
What is Goophr?
Design overview
OpenAPI specification
Goophr Concierge API definition
Goophr Librarian API definition
Project structure
Summary
Goophr Concierge
Revisiting the API definition
Document feeder – the REST API endpoint
Query handler – the REST API endpoint
Conventions
Code conventions
Diagram conventions
Logical flow diagrams
The doc processor
The doc store
The index processor
The line store
The consolidated flow diagram
Queue workers
Single stores
Buffered channels
The Concierge source code
Running tests
The Concierge server
Summary
Goophr Librarian
The standard indexing model
An example – books with an index of words
The inverted indexing model
An example – the inverted index for words in books
Ranking
Revisiting the API definition
The document indexer – the REST API endpoint
The query resolver – the REST API endpoint
Code conventions
Librarian source code
main.go
common/helpers.go
api/index.go
api/query.go
Testing Librarian
Testing feeder.go using /api/index
Testing /api/query
Summary
Deploying Goophr
Updating Goophr Concierge
Handle multiple Librarians
Aggregated search results
Orchestrating with docker-compose
Environment variables and API ports
The file server
The Goophr source code
librarian/main.go
concierge/main.go
concierge/api/query.go
simple-server/Dockerfile
simple-server/main.go
docker-compose.yaml
.env
Running Goophr with docker-compose
Adding documents to Goophr
Searching for keywords with Goophr
Search – "apple"
Search – "cake"
Search – "apple", "cake"
Individual logs with docker-compose
Authorization on a web server
secure/secure.go
secure/secure_test.go
Test results
Summary
Foundations of Web Scale Architecture
Scaling a web application
The single server instance
Separate layers for the web and database
Multiple server instances
The load balancer
Multi-availability zones
The database
SQL versus NoSQL
Which type of database should we use?
Database replication
Master-replica replication
Master-master replication
Failover cluster replication
Monolith versus microservices
Mediator design pattern
Deployment options
Maintainability of multiple instances
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
Download from finelybook www.finelybook.com Distributed Computing with Go Practical concurrency and parallelism for Go applications V.N. Nikhil Anurag 2
Download from finelybook www.finelybook.com BIRMINGHAM - MUMBAI 3
Download from finelybook www.finelybook.com Distributed Computing with Go Copyright © 2018 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Commissioning Editor: Dominic Shakeshaft Acquisition Editor: Frank Pohlmann Project Editor: Radhika Atitkar Content Development Editor: Monika Sangwan Technical Editor: Nidhisha Shetty Copy Editor: Tom Jacob Proofreader: Safis Editing Indexer: Rekha Nair Graphics: Tom Scaria Production Coordinator: Nilesh Mohite First published: February 2018 Production reference: 1270218 Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK. ISBN 978-1-78712-538-4 www.packtpub.com 4
Download from finelybook www.finelybook.com mapt.io Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website. 5
Download from finelybook www.finelybook.com Why subscribe? Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free eBook or video every month Mapt is fully searchable Copy and paste, print, and bookmark content 6
Download from finelybook www.finelybook.com PacktPub.com Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.P acktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. 7
Download from finelybook www.finelybook.com Contributors 8
分享到:
收藏