client

package
v0.0.0-...-3736fb9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Client provides an API client to the petstore service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallOption

type CallOption func(co *callOptions)

CallOptions are optional options for an RPC call.

func TraceID

func TraceID(s *string) CallOption

TraceID will cause the RPC call to execute a trace on the service and return "s" to the ID. If s == nil, this will ignore the option. If "s" is not set after the call finishes, then no trace was made.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client to the petstore service.

func New

func New(addr string) (*Client, error)

New is the constructor for Client. addr is the server's [host]:[port].

func (*Client) AddPets

func (c *Client) AddPets(ctx context.Context, pets []*pb.Pet, options ...CallOption) ([]string, error)

AddPets adds pets to the service and returns their unique identities in the same order as being added.

func (*Client) ChangeSampler

func (c *Client) ChangeSampler(ctx context.Context, sc Sampler, options ...CallOption) error

ChangeSampler changes the sampling type and rate on the server. This is and admin function that in production should be restricted.

func (*Client) DeletePets

func (c *Client) DeletePets(ctx context.Context, ids []string, options ...CallOption) error

DeletePets deletes pets with the IDs passed. If the ID doesn't exist, the system ignores it.

func (*Client) SearchPets

func (c *Client) SearchPets(ctx context.Context, filter *pb.SearchPetsReq, options ...CallOption) (chan Pet, error)

SearchPets searches the pet store for pets matching the filter. If the filter contains no entries, then all pets will be returned.

func (*Client) UpdatePets

func (c *Client) UpdatePets(ctx context.Context, pets []*pb.Pet, options ...CallOption) error

UpdatePets updates pets that already exist in the system.

type Pet

type Pet struct {
	*pb.Pet
	// contains filtered or unexported fields
}

Pet is a wrapper around a *pb.Pet that can return Go versions of fields and errors if the returned stream has an error.

func (Pet) Birthday

func (p Pet) Birthday() time.Time

Birthday returns the Pet's birthday as a time.Time.

func (Pet) Error

func (p Pet) Error() error

Error indicates if there was an error in the Pet output stream.

func (Pet) Proto

func (p Pet) Proto() *pb.Pet

Proto will give the Pet's proto representation.

type Sampler

type Sampler struct {
	// Type is the type of sampling to use.
	Type SamplerType
	// Rate is the sampling rate, only used if type is Float.
	Rate float64
}

type SamplerType

type SamplerType int32

SamplerType is the type of OTEL sampling to do.

const (
	STUnknown SamplerType = 0
	Never     SamplerType = 1
	Always    SamplerType = 2
	Float     SamplerType = 3
)

Directories

Path Synopsis
internal
server/errors
Package errors is a replacement for the golang standard library "errors".
Package errors is a replacement for the golang standard library "errors".
server/log
Package log is a replacement for the standard library log package that logs to OTEL spans contained in Context objects.
Package log is a replacement for the standard library log package that logs to OTEL spans contained in Context objects.
server/storage/mem
Package mem contains an in-memory storage implementation of storage.Data.
Package mem contains an in-memory storage implementation of storage.Data.
server/telemetry/metrics
Package metrics provides setup of metrics that can be used internally to measure various application states.
Package metrics provides setup of metrics that can be used internally to measure various application states.
server/telemetry/tracing
Package tracing provides functions for starting and stopping our Open Telemetry tracing.
Package tracing provides functions for starting and stopping our Open Telemetry tracing.
server/telemetry/tracing/sampler
Package sampler offers a Sampler that looks for a TraceID.Valid() == true or a gRPC metadata key called "trace" and if they exist will sample.
Package sampler offers a Sampler that looks for a TraceID.Valid() == true or a gRPC metadata key called "trace" and if they exist will sample.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL