Practical Go: Building Scalable Network and Non-Network Applications

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Step-by-step instruction on writing your first production-ready servers with Golang

Google's Go language, otherwise known as Golang, is a fast, simple, and reliable language that is rapidly becoming a highly popular choice for developers of all kinds. With particular utility in cloud-native environments, Golang is being adopted in major projects like Docker and Ethereum thanks to its user-friendly features, like concurrency and easy deployment.

In Practical Golang: Building Scalable Network and Non-Network Applications, expert coder and devops engineer Amit Saha delivers a step-by-step guide to writing production-ready HTTP 1.1, HTTP2, RPC, and TCP/UDP servers. Walking you through the entire process of learning this already straightforward language, from your first application to your first deployed server, the authors rely solely on the most popular open-source projects to ensure you can apply the book's advice in any cloud environment.

In this book, you'll get:

  • Fulsome descriptions of best practices on load balancing, scaling, and failure handling
  • Stepwise guidance on writing an HTTP service from scratch using only Golang's standard library
  • Easy tutorials on implementing RPC and HTTP interfaces for RPC services
  • Straightforward instructions on using SQL databases

Perfect for software developers, devops engineers, and other programming professionals, Practical Golang is also an indispensable resource for anyone who wants to go beyond the basics of Golang and deploy robust and practical servers.

Author(s): Amit Saha
Publisher: Wiley
Year: 2021

Language: English
Commentary: True PDF
Pages: 416

Cover
Title Page
Copyright Page
About the Author
About the Technical Editor
Acknowledgments
Contents at a Glance
Contents
Introduction
What Does This Book Cover?
Reader Support for This Book
Getting Started
Installing Go
Choosing an Editor
Installing Protocol Buffer Toolchain
Linux and macOS
Windows
Installing Docker Desktop
Guide to the Book
Go Modules
Command Line and Terminals
Terms
Reference Documentation
Go Refresher
Struct Type
Interface Type
Goroutines and Channels
Testing
Summary
Chapter 1 Writing Command-Line Applications
Your First Application
Writing Unit Tests
Using the Flag Package
Testing the Parsing Logic
Improving the User Interface
Removing Duplicate Error Messages
Customizing Usage Message
Accept Name via a Positional Argument
Updating the Unit Tests
Summary
Chapter 2 Advanced Command-Line Applications
Implementing Sub-commands
An Architecture for Sub-command-Driven Applications
Testing the Main Package
Testing the Cmd Package
Making Your Applications Robust
User Input with Deadlines
Handling User Signals
Summary
Chapter 3 Writing HTTP Clients
Downloading Data
Testing the Data Downloader
Deserializing Received Data
Sending Data
Working with Binary Data
Summary
Chapter 4 Advanced HTTP Clients
Using a Custom HTTP Client
Downloading from an Overloaded Server
Testing the Time-Out Behavior
Configuring the Redirect Behavior
Customizing Your Requests
Implementing Client Middleware
Understanding the RoundTripper Interface
A Logging Middleware
Add a Header to All Requests
Connection Pooling
Configuring the Connection Pool
Summary
Chapter 5 Building HTTP Servers
Your First HTTP Server
Setting Up Request Handlers
Handler Functions
Testing Your Server
The Request Struct
Method
URL
Proto, ProtoMajor, and ProtoMinor
Header
Host
Body
Form, PostForm
MultipartForm
Attaching Metadata to a Request
Processing Streaming Requests
Streaming Data as Responses
Summary
Chapter 6 Advanced HTTP Server Applications
The Handler Type
Sharing Data across Handler Functions
Writing Server Middleware
Custom HTTP Handler Technique
The HandlerFunc Technique
Chaining Middleware
Writing Tests for Complex Server Applications
Code Organization
Testing the Handler Functions
Testing the Middleware
Testing the Server Startup
Summary
Chapter 7 Production-Ready HTTP Servers
Aborting Request Handling
Strategies to Abort Request Processing
Handling Client Disconnects
Server-Wide Time-Outs
Implement a Time-Out for All Handler Functions
Implementing Server Time-Out
Implementing Graceful Shutdown
Securing Communication with TLS
Configuring TLS and HTTP/2
Testing TLS Servers
Summary
Chapter 8 Building RPC Applications with gRPC
gRPC and Protocol Buffers
Writing Your First Service
Writing the Server
Writing a Client
Testing the Server
Testing the Client
A Detour into Protobuf Messages
Marshalling and Unmarshalling
Forward and Backward Compatibility
Multiple Services
Error Handling
Summary
Chapter 9 Advanced gRPC Applications
Streaming Communication
Server-Side Streaming
Client-Side Streaming
Bidirectional Streaming
Receiving and Sending Arbitrary Bytes
Implementing Middleware Using Interceptors
Client-Side Interceptors
Server-Side Interceptors
Wrapping Streams
Chaining Interceptors
Summary
Chapter 10 Production-Ready gRPC Applications
Securing Communication with TLS
Robustness in Servers
Implementing Health Checks
Handling Runtime Errors
Aborting Request Processing
Robustness in Clients
Improving Connection Setup
Handling Transient Failures
Setting Time-Outs for Method Calls
Connection Management
Summary
Chapter 11 Working with Data Stores
Working with Object Stores
Integration with Package Server
Testing Package Uploads
Accessing Underlying Driver Types
Working with Relational Databases
Integration with Package Server
Testing Data Storage
Data Type Conversions
Using Database Transactions
Summary
Appendix A Making Your Applications Observable
Logs, Metrics, and Traces
Emitting Telemetry Data
Command-Line Applications
HTTP Applications
gRPC Applications
Summary
Appendix B Deploying Applications
Managing Configuration
Distributing Your Application
Deploying Server Applications
Summary
Index
EULA