client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrClosing = errors.New("client is closing")

Functions

This section is empty.

Types

type Caller

type Caller struct {
	Node    string
	Addr    *codec.Addr
	Method  string
	Args    any
	Reply   any
	Timeout time.Duration

	PayloadCodec codec.PayloadCodec
	// contains filtered or unexported fields
}

func NewCaller

func NewCaller(node string, addr any, method string, args any) *Caller

func (*Caller) Done

func (c *Caller) Done() (*Caller, error)

func (*Caller) IsPush

func (c *Caller) IsPush() bool

like cluster.send

func (*Caller) String

func (c *Caller) String() string

func (*Caller) WithArgs

func (c *Caller) WithArgs(args any) *Caller

func (*Caller) WithPayloadCodec

func (c *Caller) WithPayloadCodec(name string) *Caller

WithPayloadCodec registered name, For this call only

func (*Caller) WithPush

func (c *Caller) WithPush() *Caller

async send req don't waits for it to complete

func (*Caller) WithReply

func (c *Caller) WithReply(reply any) *Caller

func (*Caller) WithTimeout

func (c *Caller) WithTimeout(timeout time.Duration) *Caller

type Client

type Client struct {
	// connecting lock
	sync.Mutex

	Options Options
	Address string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(address string, opts ...Option) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) EncodePayload

func (c *Client) EncodePayload(caller *Caller) ([]byte, error)

func (*Client) Invoke

func (c *Client) Invoke(caller *Caller) error

func (*Client) IsClosing

func (c *Client) IsClosing() bool

func (*Client) Seq

func (c *Client) Seq() uint32

type Option

type Option func(*Options)

func WithCallTimeout

func WithCallTimeout(t time.Duration) Option

func WithPayloadCodec

func WithPayloadCodec(argsCodec codec.PayloadCodec) Option

type Options

type Options struct {
	PayloadCodec codec.PayloadCodec
	CallTimeout  time.Duration
}

type Req

type Req struct {
	Caller *Caller
	Error  error
	Done   chan *Req
}

Jump to

Keyboard shortcuts

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