rpc

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ALLINDEX  = 0
	INCRINDEX = 1
)

Variables

View Source
var (
	// 连接池 node_address -> connection_pool
	IndexConnPools *ConnPools = &ConnPools{M: make(map[string]*pool.ConnPool)}
	Config         RpcClientSection
)

Functions

func Init

func Init(cfg RpcClientSection, indexs []string)

func Push2Index

func Push2Index(mode int, items []*dataobj.TsdbItem, indexAddrs []string)

func ReNewPools

func ReNewPools(indexs []string) []string

Types

type ConnPools

type ConnPools struct {
	sync.RWMutex
	M           map[string]*pool.ConnPool
	MaxConns    int
	MaxIdle     int
	ConnTimeout int
	CallTimeout int
}

每个后端backend对应一个ConnPool

func CreateConnPools

func CreateConnPools(maxConns, maxIdle, connTimeout, callTimeout int, cluster []string) *ConnPools

func (*ConnPools) Call

func (this *ConnPools) Call(addr, method string, args interface{}, resp interface{}) error

同步发送, 完成发送或超时后 才能返回

func (*ConnPools) Get

func (this *ConnPools) Get(address string) (*pool.ConnPool, bool)

func (*ConnPools) UpdatePools

func (c *ConnPools) UpdatePools(addrs []string) []string

type RpcClient

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

RpcCient, 要实现io.Closer接口

func (RpcClient) Call

func (this RpcClient) Call(method string, args interface{}, reply interface{}) error

func (RpcClient) Close

func (this RpcClient) Close() error

func (RpcClient) Closed

func (this RpcClient) Closed() bool

func (RpcClient) Name

func (this RpcClient) Name() string

type RpcClientSection

type RpcClientSection struct {
	MaxConns    int `yaml:"maxConns"`
	MaxIdle     int `yaml:"maxIdle"`
	ConnTimeout int `yaml:"connTimeout"`
	CallTimeout int `yaml:"callTimeout"`
}

Jump to

Keyboard shortcuts

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