client

package
v0.0.0-...-78ff11c Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 9 Imported by: 1

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
cli
The demo will take a list of pet names and insert them into the Petstore every 1/2 a second.
The demo will take a list of pet names and insert them into the Petstore every 1/2 a second.

Jump to

Keyboard shortcuts

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