March 2021
Intermediate to advanced
260 pages
5h 45m
English
The gRPC resolver we’ll write in this section will call the GetServers endpoint we made and pass its information to gRPC so that the picker knows what servers it can route requests to.
To start, create a new package for our resolver and picker code by running $ mkdir internal/loadbalance.
gRPC uses the builder pattern for resolvers and pickers, so each has a builder interface and an implementation interface. Because the builder interfaces have one simple method—Build—we’ll implement both interfaces with one type. Create a file named resolver.go in internal/loadbalance that begins with this code:
| | package loadbalance |
| | |
| | import ( |
| | "context" |
| | "fmt" |
| | "sync" ... |
Read now
Unlock full access