package conn
import "github.com/go-kit/kit/util/conn"
Package conn provides utilities related to connections.
Index ¶
Types ¶
type AfterFunc ¶
AfterFunc imitates time.After.
type Dialer ¶
Dialer imitates net.Dial. Dialer is assumed to yield connections that are safe for use by multiple concurrent goroutines.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages a net.Conn.
Clients provide a way to create the connection with a Dialer, network, and address. Clients should Take the connection when they want to use it, and Put back whatever error they receive from its use. When a non-nil error is Put, the connection is invalidated, and a new connection is established. Connection failures are retried after an exponential backoff.
func NewManager ¶
NewManager returns a connection manager using the passed Dialer, network, and address. The AfterFunc is used to control exponential backoff and retries. For normal use, pass net.Dial and time.After as the Dialer and AfterFunc respectively. The logger is used to log errors; pass a log.NopLogger if you don't care to receive them.
func (*Manager) Put ¶
Put accepts an error that came from a previously yielded connection. If the error is non-nil, the manager will invalidate the current connection and try to reconnect, with exponential backoff. Putting a nil error is a no-op.
func (*Manager) Take ¶
Take yields the current connection. It may be nil.
Source Files ¶
- Version
- v0.2.0
- Published
- Jul 27, 2016
- Platform
- windows/amd64
- Imports
- 3 packages
- Last checked
- 3 minutes ago –
Tools for package owners.