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

The aggregator service

The next service that we will be implementing is the Aggregator type. As shown in the following code snippet, it stores a vendor ID, a list of provider addresses to query, and a list of gRPC clients for those addresses:

type Aggregator struct {
    vendorID      string
    providerAddrs []string
    clients       []proto.QuoteServiceClient
}

func NewAggregator(vendorID string, providerAddrs []string) *Aggregator {
    return &Aggregator{
        vendorID:      vendorID,
        providerAddrs: providerAddrs,
    }
}

The gRPC clients are lazily created when the Serve method is invoked:

func (a *Aggregator) Serve(ctx context.Context) (string, error) { tracer := tracer.MustGetTracer(a.vendorID) tracerClientOpt := grpc.WithUnaryInterceptor(otgrpc.OpenTracingClientInterceptor(tracer)) ...
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