pool

package
v3.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package pool is a connection pool

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	// unique id of connection
	Id() string
	// time it was created
	Created() time.Time
	// embedded connection
	transport.Client
}

Conn conn pool interface

type Option

type Option func(*Options)

Option func signature

func Size

func Size(i int) Option

Size sets the size

func TTL

func TTL(t time.Duration) Option

TTL specifies ttl

func Transport

func Transport(t transport.Transport) Option

Transport sets the transport

type Options

type Options struct {
	Transport transport.Transport
	TTL       time.Duration
	Size      int
}

Options struct

type Pool

type Pool interface {
	// Close the pool
	Close() error
	// Get a connection
	Get(ctx context.Context, addr string, opts ...transport.DialOption) (Conn, error)
	// Release the connection
	Release(c Conn, status error) error
}

Pool is an interface for connection pooling

func NewPool

func NewPool(opts ...Option) Pool

NewPool creates new connection pool

Jump to

Keyboard shortcuts

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