-
Notifications
You must be signed in to change notification settings - Fork 2
/
instrument.go
62 lines (52 loc) · 1.33 KB
/
instrument.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package dilithium
import "github.com/pkg/errors"
type Instrument interface {
NewInstance(id string) InstrumentInstance
}
type InstrumentInstance interface {
// connection
//Listener(adapter Adapter)
//Hello(adapter Adapter)
//Connected(adapter Adapter)
//ConnectionError(adapter Adapter, err error)
Closed(adapter Adapter)
// wire
WireMessageTx(wm *WireMessage)
WireMessageRetx(wm *WireMessage)
WireMessageRx(wm *WireMessage)
// UnknownPeer(peer *net.UDPAddr)
ReadError(err error)
WriteError(err error)
UnexpectedMessageType(mt messageType)
// control
TxAck(wm *WireMessage)
RxAck(wm *WireMessage)
TxKeepalive(wm *WireMessage)
RxKeepalive(wm *WireMessage)
// txPortal
TxPortalCapacityChanged(capacity int)
TxPortalSzChanged(capacity int)
TxPortalRxSzChanged(sz int)
NewRetxMs(retxMs int)
NewRetxScale(retxScale float64)
DuplicateAck(ack int32)
// rxPortal
RxPortalSzChanged(capacity int)
DuplicateRx(wm *WireMessage)
// allocation
Allocate(id string)
// instrument lifecycle
Shutdown()
}
func NewInstrument(name string, config map[string]interface{}) (i Instrument, err error) {
switch name {
case "metrics":
return NewMetricsInstrument(config)
case "nil":
return NewNilInstrument(), nil
case "trace":
return NewTraceInstrument(config)
default:
return nil, errors.Errorf("unknown instrument '%s'", name)
}
}