pool

package
v0.6.29 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxConnections int = 2
	DefaultDeadline           = 200 * time.Millisecond
)

Variables

View Source
var DefaultDnsPoolConfiguration = DnsPoolConfiguration{
	MaxConnections: DefaultMaxConnections,
}

Functions

This section is empty.

Types

type DnsPool

type DnsPool interface {
	// thread safe, will block until a connection is available
	// creates new connections until the pool is full
	Get() (*dns.Conn, error)
	// return a connection to the pool and handle network appropriate actions
	// a tcp connection will be retained, a udp connection will be closed and not reused
	// this is thread-safe but not for a given connection (which is ok because two threads probably shouldn't try and release the same connection at the same time)
	Release(conn *dns.Conn)
	// discard a connection and remove it from the pool (used for error'd connections)
	// this is thread-safe but not for a given connection (which is ok because two threads probably shouldn't try and discard the same connection at the same time)
	Discard(conn *dns.Conn)
	// shutdown enables a clean/safe shutdown of the pool
	Shutdown()
}

ConnectionPool interface for reusing existing and getting new connections

func DefaultDnsPool

func DefaultDnsPool(protocol string, address string) DnsPool

func NewDnsPool

func NewDnsPool(protocol string, address string, config DnsPoolConfiguration) DnsPool

type DnsPoolConfiguration

type DnsPoolConfiguration struct {
	// max connections this pool can hand out
	MaxConnections int
}

Jump to

Keyboard shortcuts

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