rpc_pool

package module
v0.0.0-...-e875a5a Latest Latest
Warning

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

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

README

rpc_pool

rpc pool

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnPool

type ConnPool struct {
	sync.Mutex
	RpcClis   []RcpClier
	Idx       int
	Retry     int   //异常重试次数
	ResetTime int64 // 复位连接池下标周期,单位:秒
}

func NewCreateRpcPool

func NewCreateRpcPool(addrs []string, retry, timeout, resetTime int64) *ConnPool

func (*ConnPool) AddCli

func (c *ConnPool) AddCli(cli *RpcCli)

func (*ConnPool) Call

func (c *ConnPool) Call(method string, args interface{}, reply interface{}) error

func (*ConnPool) Destroy

func (c *ConnPool) Destroy()

func (*ConnPool) GetIdx

func (c *ConnPool) GetIdx() int

func (*ConnPool) IncrIdx

func (c *ConnPool) IncrIdx()

func (*ConnPool) SetIdx

func (c *ConnPool) SetIdx(idx int)

type RcpClier

type RcpClier interface {
	Call(method string, args interface{}, reply interface{}) error
	Close()
	ServerConn() error
	GetAddr() string
}

type RpcCli

type RpcCli struct {
	sync.Mutex
	Addr    string
	Timeout time.Duration
	Cli     *rpc.Client
}

func NewRcpCli

func NewRcpCli(addr string, timeout time.Duration) *RpcCli

func (*RpcCli) Call

func (c *RpcCli) Call(method string, args interface{}, reply interface{}) error

func (*RpcCli) Close

func (c *RpcCli) Close()

func (*RpcCli) GetAddr

func (c *RpcCli) GetAddr() string

func (*RpcCli) ServerConn

func (c *RpcCli) ServerConn() error

func (*RpcCli) String

func (c *RpcCli) String() string

Jump to

Keyboard shortcuts

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