Commit 66edb630 authored by Kirill Smelkov's avatar Kirill Smelkov

xnet: Add event corresponding to network dial start

We already have TraceConnect which corresponds to event of established
network connection.

However in many test scenarios it is required to know and pause
execution right before dial is going to happen. For this introduce
TraceDial which represents event corresponding to network dialing start.
parent c95f2373
...@@ -47,12 +47,19 @@ func NetTrace(inner Networker, tracer Tracer) Networker { ...@@ -47,12 +47,19 @@ func NetTrace(inner Networker, tracer Tracer) Networker {
// Tracer is the interface that needs to be implemented by network trace receivers // Tracer is the interface that needs to be implemented by network trace receivers
type Tracer interface { type Tracer interface {
TraceNetDial(*TraceDial)
TraceNetConnect(*TraceConnect) TraceNetConnect(*TraceConnect)
TraceNetListen(*TraceListen) TraceNetListen(*TraceListen)
TraceNetTx(*TraceTx) TraceNetTx(*TraceTx)
} }
// TraceConnect is event corresponding to network connection // TraceDial is event corresponding to network dial start.
type TraceDial struct {
// XXX also put networker?
Dialer, Addr string
}
// TraceConnect is event corresponding to established network connection.
type TraceConnect struct { type TraceConnect struct {
// XXX also put networker? // XXX also put networker?
Src, Dst net.Addr Src, Dst net.Addr
...@@ -88,7 +95,7 @@ func (nt *netTrace) Name() string { ...@@ -88,7 +95,7 @@ func (nt *netTrace) Name() string {
} }
func (nt *netTrace) Dial(ctx context.Context, addr string) (net.Conn, error) { func (nt *netTrace) Dial(ctx context.Context, addr string) (net.Conn, error) {
// XXX +TraceNetDialPost ? nt.tracer.TraceNetDial(&TraceDial{Dialer: nt.inner.Name(), Addr: addr})
c, err := nt.inner.Dial(ctx, addr) c, err := nt.inner.Dial(ctx, addr)
if err != nil { if err != nil {
return nil, err return nil, err
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment