Documentation
¶
Overview ¶
Package sud provides Single Use Dialers.
A single use dialer allows injecting a pre-established net.Conn into components that expect to control dialing themselves, such as [http.Transport]. The first dial succeeds and returns the injected connection; subsequent dials fail with ErrNoConnReuse.
The name "sud" is an acronym for "Single Use Dialer" (and also means "south" in Italian, which is a nice coincidence).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoConnReuse = errors.New("cannot reuse connection")
ErrNoConnReuse is the type of error returned when you create a *SingleUseDialer and you dial more than once.
Functions ¶
This section is empty.
Types ¶
type SingleUseDialer ¶
type SingleUseDialer struct {
// contains filtered or unexported fields
}
SingleUseDialer is the Dialer returned by NewSingleUseDialer.
func NewSingleUseDialer ¶
func NewSingleUseDialer(conn net.Conn) *SingleUseDialer
NewSingleUseDialer returns a "single use" dialer. The first dial will succeed and return the net.Conn regardless of the arguments passed to the dialing functions. Subsequent dial returns ErrNoConnReuse.
func (*SingleUseDialer) DialContext ¶
func (sud *SingleUseDialer) DialContext(ctx context.Context, network string, addr string) (net.Conn, error)
DialContext dials once with the configured connection and then returns ErrNoConnReuse.
This method signature is compatible with the net/http package.
All arguments are ignored and we return the connection (once) or ErrNoConnReuse.
func (*SingleUseDialer) DialTLSContext ¶
func (d *SingleUseDialer) DialTLSContext( ctx context.Context, network, address string, cfg *tls.Config) (net.Conn, error)
DialTLSContext dials once with the configured connection and then returns ErrNoConnReuse.
This method signature is compatible with the golang.org/x/net/http2 package.
All arguments are ignored and we return the connection (once) or ErrNoConnReuse.