client

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options)

func OptBodyCodec added in v1.0.1

func OptBodyCodec(c string) Option

OptBodyCodec 设置消息内容编解码器

func OptContextAge added in v1.0.1

func OptContextAge(n time.Duration) Option

OptContextAge 设置单次请求生命周期

func OptCustomService added in v1.0.1

func OptCustomService(service *registry.Service) Option

OptCustomService 自定义service

func OptGlobalPlugin added in v1.0.1

func OptGlobalPlugin(plugin ...drpc.Plugin) Option

OptGlobalPlugin 设置插件

func OptHeartbeatTime added in v1.0.1

func OptHeartbeatTime(t time.Duration) Option

OptHeartbeatTime 设置心跳包时间

func OptLocalIP added in v1.0.1

func OptLocalIP(addr string) Option

OptLocalIP 设置本地监听的地址

func OptMetrics added in v1.1.0

func OptMetrics(m metrics.Metrics) Option

OptMetrics 设置统计数据接口

func OptNetwork added in v1.0.1

func OptNetwork(net string) Option

OptNetwork 设置网络类型

func OptPrintDetail added in v1.0.1

func OptPrintDetail(c bool) Option

OptPrintDetail 是否打印消息详情

func OptProtoFunc added in v1.0.1

func OptProtoFunc(pf proto.ProtoFunc) Option

OptProtoFunc 设置协议方法

func OptRegistry added in v1.0.1

func OptRegistry(r registry.Registry) Option

OptRegistry 设置服务注册中心

func OptRetryTimes added in v1.0.1

func OptRetryTimes(n int) Option

OptRetryTimes 设置重试次数

func OptSelector added in v1.0.1

func OptSelector(s selector.Selector) Option

OptSelector 设置选择器

func OptServiceName added in v1.0.1

func OptServiceName(name string) Option

OptServiceName 设置服务名称

func OptServiceVersion added in v1.0.1

func OptServiceVersion(version string) Option

OptServiceVersion 当前服务版本

func OptSessionAge added in v1.0.1

func OptSessionAge(n time.Duration) Option

OptSessionAge 设置会话生命周期

func OptSlowCometDuration added in v1.0.1

func OptSlowCometDuration(n time.Duration) Option

OptSlowCometDuration 设置慢请求的定义时间

func OptTlsConfig added in v1.0.1

func OptTlsConfig(config *tls.Config) Option

OptTlsConfig 设置证书对象

func OptTlsFile added in v1.0.1

func OptTlsFile(tlsCertFile string, tlsKeyFile string) Option

OptTlsFile 设置证书内容

type Options

type Options struct {
	Context           context.Context // 上下文
	ServiceName       string          // 服务名称
	ServiceVersion    string          // 服务版本
	Network           string          // 网络类型
	LocalIP           string          // 本地网络
	TlsCertFile       string
	TlsKeyFile        string
	TLSConfig         *tls.Config
	ProtoFunc         proto.ProtoFunc
	SessionAge        time.Duration
	ContextAge        time.Duration
	DialTimeout       time.Duration
	SlowCometDuration time.Duration
	BodyCodec         string
	PrintDetail       bool
	HeartbeatTime     time.Duration
	RetryTimes        int
	GlobalPlugin      []drpc.Plugin
	Registry          registry.Registry
	Selector          selector.Selector
	Metrics           metrics.Metrics // 统计信息
}

func NewOptions

func NewOptions(options ...Option) Options

NewOptions 初始化配置

func (*Options) EndpointConfig

func (that *Options) EndpointConfig() drpc.EndpointConfig

type RpcClient

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

RpcClient rpc客户端结构体

func NewRpcClient

func NewRpcClient(serviceName string, opt ...Option) *RpcClient

NewRpcClient 创建rpc客户端

func (*RpcClient) AsyncCall

func (that *RpcClient) AsyncCall(serviceMethod string, arg interface{}, result interface{}, callCmdChan chan<- drpc.CallCmd, setting ...message.MsgSetting) drpc.CallCmd

AsyncCall 异步请求

func (*RpcClient) Call

func (that *RpcClient) Call(serviceMethod string, args interface{}, result interface{}, setting ...message.MsgSetting) drpc.CallCmd

Call 请求服务端

func (*RpcClient) Close

func (that *RpcClient) Close()

Close 关闭客户端对象

func (*RpcClient) Endpoint

func (that *RpcClient) Endpoint() drpc.Endpoint

Endpoint 返回Endpoint对象

func (*RpcClient) Options

func (that *RpcClient) Options() Options

Options 获取配置信息

func (*RpcClient) Push

func (that *RpcClient) Push(serviceMethod string, arg interface{}, setting ...message.MsgSetting) *drpc.Status

Push 发送push消息

func (*RpcClient) RoutePush

func (that *RpcClient) RoutePush(ctrlStruct interface{}, plugin ...drpc.Plugin) []string

RoutePush 使用结构体注册PUSH处理程序,并且返回地址

func (*RpcClient) RoutePushFunc

func (that *RpcClient) RoutePushFunc(pushHandleFunc interface{}, plugin ...drpc.Plugin) string

RoutePushFunc 使用函数注册PUSH处理程序,并且返回地址

func (*RpcClient) SubRoute

func (that *RpcClient) SubRoute(pathPrefix string, plugin ...drpc.Plugin) *drpc.SubRouter

SubRoute 设置服务的路由组

Jump to

Keyboard shortcuts

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