transport

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoAvailableClients = errors.New("no available clients")
	ErrNoAvailableServers = errors.New("no servers available for connection")
)

Functions

This section is empty.

Types

type ClientsPool

type ClientsPool interface {
	NextLive() (*NodeClient, error)
	NextDead() (*NodeClient, error)
	OnFailure(c *NodeClient)
	OnSuccess(c *NodeClient)
}

func NewClientsPool

func NewClientsPool(servers []string, insecure bool) (pool ClientsPool, err error)

type ClusterPool

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

func (*ClusterPool) NextDead

func (p *ClusterPool) NextDead() (*NodeClient, error)

func (*ClusterPool) NextLive

func (p *ClusterPool) NextLive() (*NodeClient, error)

func (*ClusterPool) OnFailure

func (p *ClusterPool) OnFailure(c *NodeClient)

func (*ClusterPool) OnSuccess

func (p *ClusterPool) OnSuccess(c *NodeClient)

type Config

type Config struct {
	Servers        []string
	Insecure       bool
	RequestTimeout time.Duration
	PingInterval   time.Duration
	SuccessCodes   []int
}

type NodeClient

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

func NewNodeClient

func NewNodeClient(dsn string, transport http.RoundTripper) (*NodeClient, error)

NewNodeClient create log hole node client.

func (*NodeClient) ActiveRequests

func (c *NodeClient) ActiveRequests() int

ActiveRequests returns all active request of node client.

func (*NodeClient) LastUseTime

func (c *NodeClient) LastUseTime() int

LastUseTime returns time of last started request.

func (*NodeClient) PingRequest

func (c *NodeClient) PingRequest(timeout time.Duration) (code int, err error)

Ping request allows to check connection status.

func (*NodeClient) SendRequest

func (c *NodeClient) SendRequest(body []byte, timeout time.Duration) (code int, err error)

type NodeConfig

type NodeConfig struct {
	Host      string
	AuthToken string
}

type SinglePool

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

func (*SinglePool) NextDead

func (p *SinglePool) NextDead() (*NodeClient, error)

func (*SinglePool) NextLive

func (p *SinglePool) NextLive() (*NodeClient, error)

func (*SinglePool) OnFailure

func (p *SinglePool) OnFailure(c *NodeClient)

func (*SinglePool) OnSuccess

func (p *SinglePool) OnSuccess(c *NodeClient)

type Transport

type Transport interface {
	Send(body []byte) error
	IsConnected() bool
	IsReconnected() <-chan struct{}
}

func New

func New(config Config) (Transport, error)

Jump to

Keyboard shortcuts

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