January 2020
Intermediate to advanced
640 pages
16h 56m
English
The first and easiest service to implement is Provider. The following is the definition for the Provider type and its constructor:
type Provider struct { vendorID string } func NewProvider(vendorID string) *Provider { return &Provider{ vendorID: vendorID } }
Next, we will implement the GetQuote method, as specified in the preceding protocol buffer definitions. To keep our example as simple as possible, we will provide a dummy implementation that returns a single quote with a random price value and the vendorID value that was passed as an argument to the NewProvider constructor:
func (p *Provider) GetQuote(ctx context.Context, req *proto.QuotesRequest) (*proto.QuotesResponse, error) { return &proto.QuotesResponse{ Quotes: ...