transport

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New(cfg *Config) (*Client, error)

func (*Client) Perform

func (c *Client) Perform(req *http.Request) (*http.Response, error)

type Config

type Config struct {
	Servers            []string
	Username           string
	Password           string
	MaxRetries         int
	Transport          http.RoundTripper
	ConnectionPoolFunc func([]*Connection, Selector) ConnectionPool
	// contains filtered or unexported fields
}

type Connection

type Connection struct {
	sync.Mutex

	URL       *url.URL
	IsDead    bool
	DeadSince time.Time
	Failures  int

	ID         string
	Name       string
	Roles      []string
	Attributes map[string]interface{}
}

Connection represents a connection to a node.

func (*Connection) String

func (c *Connection) String() string

String returns a readable connection representation.

type ConnectionPool

type ConnectionPool interface {
	Next() (*Connection, error)  // Next returns the next available connection.
	OnSuccess(*Connection) error // OnSuccess reports that the connection was successful.
	OnFailure(*Connection) error // OnFailure reports that the connection failed.
	URLs() []*url.URL            // URLs returns the list of URLs of available connections.
}

ConnectionPool defines the interface for the connection pool.

func NewConnectionPool

func NewConnectionPool(conns []*Connection, selector Selector) (ConnectionPool, error)

NewConnectionPool creates and returns a default connection pool.

type Interface

type Interface interface {
	Perform(*http.Request) (*http.Response, error)
}

type Selector

type Selector interface {
	Select([]*Connection) (*Connection, error)
}

Selector defines the interface for selecting connections from the pool.

Jump to

Keyboard shortcuts

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