client

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithValueCallOption

func WithValueCallOption(ctx context.Context, cs *CallSettings) context.Context

WithValueCallOption returns a new Context that carries value.

Types

type Address

type Address struct {
	Addr     string
	Weight   int
	Metadata map[string]string
}

type Balancer

type Balancer interface {
	Select() (*Address, error)
	Update([]*Address)
}

type CallOption

type CallOption func(cs *CallSettings)

CallOption is an option used by Invoke to control behaviors of RPC calls. CallOption works by modifying relevant fields of CallSettings.

func WithCoAccept

func WithCoAccept(accept string) CallOption

WithCoAccept use encoding.MIMExxx

func WithCoContentType

func WithCoContentType(contentType string) CallOption

WithCoContentType use encoding.MIMExxx

func WithCoHeader

func WithCoHeader(k, v string) CallOption

WithCoHeader

func WithCoNoAuth

func WithCoNoAuth() CallOption

WithCoNoAuth

func WithCoPath

func WithCoPath(path string) CallOption

WithCoPath

type CallSettings

type CallSettings struct {

	// Path overwrite api call
	Path string
	// contains filtered or unexported fields
}

CallSettings allow fine-grained control over how calls are made.

func DefaultCallOption deprecated

func DefaultCallOption(path string, opts ...CallOption) CallSettings

Deprecated: use Client.CallSetting(path string, opts ...CallOption) api.

func FromValueCallOption

func FromValueCallOption(ctx context.Context) (cs CallSettings, ok bool)

FromValueCallOption returns the CallSettings value stored in ctx, if any.

func MustFromValueCallOption

func MustFromValueCallOption(ctx context.Context) *CallSettings

MustFromValueCallOption returns the CallSettings value stored in ctx.

type Client

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

func NewClient

func NewClient(opts ...Option) *Client

func (*Client) CallSetting

func (c *Client) CallSetting(path string, cos ...CallOption) *CallSettings

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, path string, req, resp any, opts ...CallOption) error

Delete method does DELETE HTTP request. It's defined in section 4.3.5 of RFC7231.

func (*Client) Deref

func (c *Client) Deref() *resty.Client

func (*Client) EncodeQuery

func (c *Client) EncodeQuery(v any) (string, error)

EncodeQuery encode v into “URL encoded” form ("bar=baz&foo=quux") sorted by key.

func (*Client) EncodeURL

func (c *Client) EncodeURL(pathTemplate string, msg any, needQuery bool) string

EncodeURL encode msg to url path. pathTemplate is a template of url path like http://helloworld.dev/{name}/sub/{sub.name}.

func (*Client) Execute

func (c *Client) Execute(ctx context.Context, method, path string, req, resp any, opts ...CallOption) error

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, req, resp any, opts ...CallOption) error

Get method does GET HTTP request. It's defined in section 4.3.1 of RFC7231.

func (*Client) Head

func (c *Client) Head(ctx context.Context, path string, req, resp any, opts ...CallOption) error

Head method does HEAD HTTP request. It's defined in section 4.3.2 of RFC7231.

func (*Client) Invoke

func (c *Client) Invoke(ctx context.Context, method, path string, in, out any, settings *CallSettings) error

Invoke the request NOTE: Do not use this function. use Execute instead.

func (*Client) Options

func (c *Client) Options(ctx context.Context, path string, req, resp any, opts ...CallOption) error

Options method does OPTIONS HTTP request. It's defined in section 4.3.7 of RFC7231.

func (*Client) Patch

func (c *Client) Patch(ctx context.Context, path string, req, resp any, opts ...CallOption) error

Patch method does PATCH HTTP request. It's defined in section 2 of RFC5789.

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, req, resp any, opts ...CallOption) error

Post method does POST HTTP request. It's defined in section 4.3.3 of RFC7231.

func (*Client) Put

func (c *Client) Put(ctx context.Context, path string, req, resp any, opts ...CallOption) error

Put method does PUT HTTP request. It's defined in section 4.3.4 of RFC7231.

func (*Client) Use

func (c *Client) Use(mws ...Middleware) *Client

type ClientOption

type ClientOption func(*Client)

type Handler

type Handler func(ctx context.Context, req interface{}) (interface{}, error)

type Middleware

type Middleware func(Handler) Handler

func Chain

func Chain(m ...Middleware) Middleware

type Option

type Option interface {
	// contains filtered or unexported methods
}

func Registry

func Registry(r registry.Registry) Option

func WithCallOption

func WithCallOption(co ...CallOption) Option

WithCallOption WithCallOption(WithCoNoAuth)

func WithEncoding

func WithEncoding(codec *wencoding.Encoding) Option

func WithServiceAddr

func WithServiceAddr(addr string) Option

func WithServiceName

func WithServiceName(name string) Option

func WithTokenSource

func WithTokenSource(t oauth2.TokenSource) Option

func WithValidate

func WithValidate(f func(any) error) Option

type Peer

type Peer struct {
	Addr *Address
	// contains filtered or unexported fields
}

type RR

type RR struct {
	Nodes []*Address
	Next  int
}

func (*RR) Select

func (r *RR) Select() (*Address, error)

func (*RR) Update

func (r *RR) Update(addresses []*Address)

type Resolver

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

func (*Resolver) Close

func (r *Resolver) Close()

type Target

type Target struct {
	Scheme    string
	Authority string
	Endpoint  string
}

type Wrr

type Wrr struct {
	Next int
	// contains filtered or unexported fields
}

func (*Wrr) Select

func (w *Wrr) Select() (*Address, error)

func (*Wrr) Update

func (w *Wrr) Update(addresses []*Address)

Jump to

Keyboard shortcuts

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