Skip to Content
Hands-On Software Engineering with Golang
book

Hands-On Software Engineering with Golang

by Achilleas Anagnostopoulos
January 2020
Intermediate to advanced
640 pages
16h 56m
English
Packt Publishing
Content preview from Hands-On Software Engineering with Golang

Putting it all together

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Software Architecture with Golang

Hands-On Software Architecture with Golang

Jyotiswarup Raiturkar

Publisher Resources

ISBN: 9781838554491Supplemental Content