Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 Selector ¶
type Selector interface {
Select([]*Connection) (*Connection, error)
}
Selector defines the interface for selecting connections from the pool.
Click to show internal directories.
Click to hide internal directories.