Documentation ¶
Overview ¶
Package xnet provides addons to std package net.
Index ¶
- func BindCtxL(l Listener, ctx context.Context) net.Listener
- type Listener
- type Networker
- type TraceConnect
- type TraceDial
- type TraceListen
- type TraceReceiver
- type TraceTx
- type Tracer
- func (t *Tracer) Close() error
- func (t *Tracer) Dial(ctx context.Context, addr string) (net.Conn, error)
- func (t *Tracer) Listen(ctx context.Context, laddr string) (Listener, error)
- func (t *Tracer) Name() string
- func (t *Tracer) Network() string
- func (t *Tracer) TraceOff()
- func (t *Tracer) TraceOn()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Listener ¶
type Listener interface { Accept(ctx context.Context) (net.Conn, error) // same as in net.Listener Close() error Addr() net.Addr }
Listener amends net.Listener for Accept to handle cancellation.
type Networker ¶
type Networker interface { // Network returns name of the network. Network() string // Name returns name of the access-point on the network. // // Example of name is local hostname if networker provides access to // OS-level dial/listen. Name() string // Dial connects to addr on underlying network. // // See net.Dial for semantic details. Dial(ctx context.Context, addr string) (net.Conn, error) // Listen starts listening on local address laddr on underlying network access-point. // // See net.Listen for semantic details. Listen(ctx context.Context, laddr string) (Listener, error) // Close releases resources associated with the network access-point. // // In-progress and future network operations such as Dial and Listen, // originated via this access-point, will return with an error. Close() error }
Networker is interface representing access-point to a streaming network.
type TraceConnect ¶
TraceConnect is event corresponding to established network connection.
type TraceDial ¶
type TraceDial struct {
// XXX also put networker?
Dialer, Addr string
}
TraceDial is event corresponding to network dial start.
type TraceListen ¶
TraceListen is event corresponding to network listening.
type TraceReceiver ¶
type TraceReceiver interface { TraceNetDial(*TraceDial) TraceNetConnect(*TraceConnect) TraceNetListen(*TraceListen) TraceNetTx(*TraceTx) }
TraceReceiver is the interface that needs to be implemented by network trace receivers.
type Tracer ¶
type Tracer struct {
// contains filtered or unexported fields
}
Tracer wraps underlying Networker to emit events on networking operations.
Create it via NetTrace.
func NetTrace ¶
func NetTrace(inner Networker, tracerx TraceReceiver) *Tracer
NetTrace wraps underlying networker with IO tracing layer.
Tracing is done via calling trace func right after corresponding networking event happenned. No synchronization for notification is performed - if one is required tracing func must implement such synchronization itself.
only initiation events are traced:
1. Tx only (no Rx):
- because Write, contrary to Read, never writes partial data on non-error
- because in case of pipenet tracing writes only is enough to get whole network exchange picture
2. Dial only (no Accept)
- for similar reasons.
WARNING NetTrace functionality is currently very draft.
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
virtnettest
Package virtnettest provides basic tests to be run on virtnet network implementations.
|
Package virtnettest provides basic tests to be run on virtnet network implementations. |
Package lonet provides TCP network simulated on top of localhost TCP loopback.
|
Package lonet provides TCP network simulated on top of localhost TCP loopback. |
Package pipenet provides TCP-like synchronous in-memory network of net.Pipes.
|
Package pipenet provides TCP-like synchronous in-memory network of net.Pipes. |
Package virtnet provides infrastructure for TCP-like virtual networks.
|
Package virtnet provides infrastructure for TCP-like virtual networks. |