service

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitPool

func InitPool()

Types

type RpcConn

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

RpcConn 封装RPC客户端

type RpcConnector

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

RpcConnector RPC连接器

func NewRpcConnector

func NewRpcConnector(rpcServerAddr string) RpcConnector

NewRpcConnector 创建RPC连接器

func (*RpcConnector) Close

func (c *RpcConnector) Close(client *rpc.Client)

Close 关闭RPC客户端对连接

func (*RpcConnector) Connect

func (c *RpcConnector) Connect(ctx context.Context) (*rpc.Client, error)

Connect 连接RPC服务器,返回客户端

type RpcPool

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

RpcPool RPC连接池

var Pool *RpcPool

func NewRpcPool

func NewRpcPool(connector RpcConnector, config *RpcPoolConfig) *RpcPool

NewRpcPool 构造一个RPC连接池

func (*RpcPool) Close

func (rp *RpcPool) Close()

Close 关闭连接池

func (*RpcPool) Exec

func (rp *RpcPool) Exec(handle func(client *rpc.Client)) error

Exec 执行函数,返回结果 🤣 基于golang闭包的大一统接口

func (*RpcPool) Stat

func (rp *RpcPool) Stat() RpcPoolStats

Stat 获取连接池的状态

type RpcPoolConfig

type RpcPoolConfig struct {
	InitialCount int
	MaxOpenCount int
	MaxIdleCount int
	MaxLifeTime  time.Duration
	MaxIdleTime  time.Duration
}

RpcPoolConfig RPC连接池配置

type RpcPoolStats

type RpcPoolStats struct {
	MaxOpenCount int
	MaxIdleCount int

	OpenNum int
	Idle    int
	InUse   int

	WaitCount         int64
	MaxIdleClosed     int64
	MaxIdleTimeClosed int64
	MaxLifeTimeClosed int64
}

RpcPoolStats RPC连接池状态

Jump to

Keyboard shortcuts

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