pool

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FailoverPool

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

FailoverPool is a pool of connections to lite servers that implements a failover strategy and in case of failure it'll automatically switch to a working connection.

The failover strategy is as follows: given a list of connections, a pool uses the first connection from the list that is 1. working 2. not more than 1 block behind the head of masterchain.

func NewFailoverPool

func NewFailoverPool(clients []*liteclient.Client) *FailoverPool

NewFailoverPool returns a new instance of a failover pool. The given list of clients is ordered by priority and starts with a connection with the highest priority.

func (*FailoverPool) BestMasterchainServer

func (p *FailoverPool) BestMasterchainServer() *liteclient.Client

func (*FailoverPool) BestServerByAccountID

func (p *FailoverPool) BestServerByAccountID(tongo.AccountID) (*liteclient.Client, error)

func (*FailoverPool) BestServerByBlockID

func (p *FailoverPool) BestServerByBlockID(tongo.BlockID) (*liteclient.Client, error)

func (*FailoverPool) ConnectionsNumber

func (p *FailoverPool) ConnectionsNumber() int

ConnectionsNumber returns a number of connections in this pool.

func (*FailoverPool) Run

func (p *FailoverPool) Run(ctx context.Context)

Jump to

Keyboard shortcuts

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