Practical Go. Building Scalable Network & Non-Network Applications / Практический Go. Создание масштабируемых сетевых и несетевых приложений
Год издания: 2022
Автор: Amit Saha
Издательство: Wiley
ISBN: 978-1-119-77382-5
Язык: Английский
Формат: PDF
Качество: Издательский макет или текст (eBook)
Интерактивное оглавление: Да
Количество страниц: 419
Описание: In this book, you will learn to use the Go programming language to build robust, production-ready software applications. You will learn just enough to building command line tools and applications communicating over HTTP and gRPC.
В этой книге вы научитесь использовать язык программирования Go для создания надежных, готовых к эксплуатации программных приложений. Вы узнаете достаточно, чтобы создавать инструменты командной строки и приложения, взаимодействующие через HTTP и gRPC.
Оглавление
Introduction
Getting Started
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