client

package
v0.0.0-...-93144e6 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

client 当项目有对外提供服务时, client 协助使用者方便高效的使用服务. 一般用于 rpc 服务, 该 pkg 提供 ServiceClient 的创建, 以及相关函数的封装, 或添加部分自定义逻辑(如校验), 从而用起来更方便高效.

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 IClient

type IClient interface {
	Close() error
}

IClient Client 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