client

package
v0.0.0-...-76745ad Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: BSD-3-Clause Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallOption

type CallOption func(req *nh.Request)

CallOption 调用选项

func WithNoReply

func WithNoReply() CallOption

WithNoReply 不需要回复

func WithNode

func WithNode(nodeID string) CallOption

WithNode 指定节点

func WithStream

func WithStream(stream string) CallOption

WithStream 指定流

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client 客户端

func New

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

New 创建客户端

func NewQUIC

func NewQUIC(dialURL string, tlsConfig *tls.Config, quicConfig *quic.Config) (*Client, error)

NewQUIC 创建QUIC客户端

func (*Client) Call

func (cli *Client) Call(ctx context.Context, serviceCode int32, method string, input, output proto.Message, options ...CallOption) error

Call 发送请求

func (*Client) CallNoReply

func (cli *Client) CallNoReply(ctx context.Context, serviceCode int32, method string, input proto.Message, options ...CallOption) error

CallNoReply 发送无需回复的请求

func (*Client) Close

func (cli *Client) Close()

Close 关闭客户端

func (*Client) Subscribe

func (cli *Client) Subscribe(ctx context.Context, serviceCode int32, messageCode int32, callback any)

Subscribe 订阅指定类型消息

Example:

client.Subscribe(ctx, gateway.ServiceCode, int32(gatewaypb.Protocol_RPC_ERROR), func(msg *gatewaypb.RPCError, reply *nh.Reply) {
	// ...
})

Jump to

Keyboard shortcuts

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