Documentation
¶
Overview ¶
Package connection manages (abstract) connections with retrying and reconnection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UsingConnection ¶ added in v0.13.0
func UsingConnection[T any](ctx context.Context, r *Reconnector, desc string, cb func(cli Connection) (T, error)) (T, error)
UsingConnection invokes the provided callback for a Connection.
Types ¶
type Connection ¶
Connection encapsulates a single connection.
type ConnectorImpl ¶
type ConnectorImpl interface { NewConnection(ctx context.Context) (Connection, error) IsConnectionClosedError(err error) bool }
ConnectorImpl provides a set of methods to manage connections.
type Reconnector ¶
type Reconnector struct {
// contains filtered or unexported fields
}
Reconnector manages active Connection with automatic retrying and reconnection.
func NewReconnector ¶
func NewReconnector(conn ConnectorImpl) *Reconnector
NewReconnector creates a new Pool for a given connector.
func (*Reconnector) CloseActiveConnection ¶
func (r *Reconnector) CloseActiveConnection(ctx context.Context)
CloseActiveConnection closes the active connection if any.
func (*Reconnector) GetOrOpenConnection ¶
func (r *Reconnector) GetOrOpenConnection(ctx context.Context) (Connection, error)
GetOrOpenConnection gets or establishes new connection and returns it.
func (*Reconnector) UsingConnectionNoResult ¶
func (r *Reconnector) UsingConnectionNoResult(ctx context.Context, desc string, cb func(cli Connection) error) error
UsingConnectionNoResult invokes the provided callback for a Connection.
Click to show internal directories.
Click to hide internal directories.