connection

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package connection manages (abstract) connections with retrying and reconnection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	fmt.Stringer
	io.Closer
}

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) UsingConnection

func (r *Reconnector) UsingConnection(ctx context.Context, desc string, cb func(cli Connection) (interface{}, error)) (interface{}, error)

UsingConnection invokes the provided callback for a Connection.

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.

Jump to

Keyboard shortcuts

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