January 2020
Intermediate to advanced
640 pages
16h 56m
English
The main file prepares a microservice deployment environment via a call to the deployServices helper function. The idea here is to string together the services in such a manner so that tracing a request through the system will yield an interesting trace graph. Let's see how this is done.
First, the helper starts three Provider instances and keeps track of their addresses:
var err error providerAddrs := make([]string, 3) for i := 0; i < len(providerAddrs); i++ { provider := service.NewProvider(fmt.Sprintf("vendor-%d", i)) if providerAddrs[i], err = provider.Serve(ctx); err != nil { return nil, err } }
Then, it starts an Aggregator instance and sets it up to connect to providers 1 and 2 from the preceding list:
aggr1 ...