mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-03 07:26:45 +00:00
websocket: add SendMessageReturnResponse latency reporter (#1031)
* add websocket sync request latency reporter * add globalReporter similar to request package * gofmt * connection level reporter and test * fix SetupNewConnection
This commit is contained in:
@@ -46,6 +46,14 @@ var (
|
||||
errClosedConnection = errors.New("use of closed network connection")
|
||||
)
|
||||
|
||||
var globalReporter Reporter
|
||||
|
||||
// SetupGlobalReporter sets a reporter interface to be used
|
||||
// for all exchange requests
|
||||
func SetupGlobalReporter(r Reporter) {
|
||||
globalReporter = r
|
||||
}
|
||||
|
||||
// New initialises the websocket struct
|
||||
func New() *Websocket {
|
||||
return &Websocket{
|
||||
@@ -183,6 +191,14 @@ func (w *Websocket) SetupNewConnection(c ConnectionSetup) error {
|
||||
connectionURL = c.URL
|
||||
}
|
||||
|
||||
if c.ConnectionLevelReporter == nil {
|
||||
c.ConnectionLevelReporter = w.ExchangeLevelReporter
|
||||
}
|
||||
|
||||
if c.ConnectionLevelReporter == nil {
|
||||
c.ConnectionLevelReporter = globalReporter
|
||||
}
|
||||
|
||||
newConn := &WebsocketConnection{
|
||||
ExchangeName: w.exchangeName,
|
||||
URL: connectionURL,
|
||||
@@ -195,6 +211,7 @@ func (w *Websocket) SetupNewConnection(c ConnectionSetup) error {
|
||||
Wg: w.Wg,
|
||||
Match: w.Match,
|
||||
RateLimit: c.RateLimit,
|
||||
Reporter: c.ConnectionLevelReporter,
|
||||
}
|
||||
|
||||
if c.Authenticated {
|
||||
|
||||
Reference in New Issue
Block a user