client

package
v0.0.0-...-ab8afbf Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client Base grpc client

func NewClient

func NewClient(opts Options) (*Client, error)

NewClient NewClient

func (*Client) Close

func (c *Client) Close() error

Close 关闭客户端连接

type DemoClient

type DemoClient struct {
	IClient
	pb.DemoServiceClient
}

DemoClient Demo rpc client

func NewDemoClient

func NewDemoClient(opts Options) (*DemoClient, error)

NewDemoClient 创建一个连接 demo 的 gRPC 客户端。

type IClient

type IClient interface {
	Close() error
}

IClient Client interface

type IDemoClient

type IDemoClient interface {
	IClient
	pb.DemoServiceClient
}

IDemoClient DemoClient interface

type Options

type Options struct {
	// Address 服务的地址,IP和端口
	Address string `json:"address" yaml:"address" mapstructure:"address"`

	// DialTimeout 连接超时时间,单位秒
	DialTimeout int64 `json:"dial_timeout" yaml:"dial_timeout" mapstructure:"dial_timeout"`

	// KeepAliveTime 连接保活周期,单位秒
	KeepAliveTime int64 `json:"keep_alive_time" yaml:"keep_alive_time" mapstructure:"keep_alive_time"`

	// KeepAliveTimeout 发送保活心跳包的超时时间,单位秒
	KeepAliveTimeout int64 `json:"keep_alive_timeout" yaml:"keep_alive_timeout" mapstructure:"keep_alive_timeout"`
}

Options 客户端连接参数。

Jump to

Keyboard shortcuts

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