March 2021
Intermediate to advanced
260 pages
5h 45m
English
In the gRPC architecture, pickers handle the RPC balancing logic. They’re called pickers because they pick a server from the servers discovered by the resolver to handle each RPC. Pickers can route RPCs based on information about the RPC, client, and server, so their utility goes beyond balancing to any kind of request-routing logic.
To implement the picker builder, create a file named picker.go in internal/loadbalance that begins with this code:
| | package loadbalance |
| | |
| | import ( |
| | "strings" |
| | "sync" |
| | "sync/atomic" |
| | |
| | "google.golang.org/grpc/balancer" |
| | "google.golang.org/grpc/balancer/base" |
| | ) |
| | |
| | var _ base.PickerBuilder = (*Picker)(nil) ... |
Read now
Unlock full access