pool

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balancer

type Balancer interface {
	Get(nodes []NodeMeta) (NodeMeta, error)
}

Balancer is an interface to switch node from the pool

type Conn

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

Conn represents connection within pool

func (*Conn) Close

func (c *Conn) Close() error

Close releases connection back to the node pool

func (*Conn) Conn

func (c *Conn) Conn() *conn.Conn

Conn gets underlying RPC connection

type DefaultBalancer

type DefaultBalancer struct {
	Balancer
}

DefaultBalancer is default balancer

func (*DefaultBalancer) Get

func (b *DefaultBalancer) Get(nodes []NodeMeta) (NodeMeta, error)

Get picks a node from the pool of nodes

type NodeMeta

type NodeMeta struct {
	Address          string
	Available        bool
	BusyConnections  int32
	PendingConsumers int32
}

NodeMeta contains node's metadata for balancer

type NodePool

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

NodePool is a connections pool of any single node

func (*NodePool) Available

func (p *NodePool) Available() bool

Available check

func (*NodePool) Close

func (p *NodePool) Close() error

Close pool

func (*NodePool) ConsumedConnections

func (p *NodePool) ConsumedConnections() int32

ConsumedConnections count

func (*NodePool) Get

func (p *NodePool) Get(timeout time.Duration) (*Conn, error)

Get connection

func (*NodePool) NotifyClose

func (p *NodePool) NotifyClose()

NotifyClose pool

func (*NodePool) PendingConsumers

func (p *NodePool) PendingConsumers() int32

PendingConsumers count

type Pool

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

Pool is a pool of pools (nodes) of connections

func New

func New(bal Balancer) *Pool

New Pool instance

func (*Pool) AddNode

func (p *Pool) AddNode(addr string, concurrency uint16, copts conn.Options) bool

AddNode adds a new node to the pool

func (*Pool) Close

func (p *Pool) Close() error

Close closes the pool and waits for completion

func (*Pool) Get

func (p *Pool) Get(timeout time.Duration) (*conn.Conn, func(), error)

Get gets free *conn.Conn from the pool

Jump to

Keyboard shortcuts

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