mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
bbgo: add session connection notification
This commit is contained in:
parent
8995ce2824
commit
cfc66dc13e
|
@ -322,6 +322,16 @@ func (session *ExchangeSession) Init(ctx context.Context, environ *Environment)
|
|||
// forward trade updates and order updates to the order executor
|
||||
session.UserDataStream.OnTradeUpdate(session.OrderExecutor.EmitTradeUpdate)
|
||||
session.UserDataStream.OnOrderUpdate(session.OrderExecutor.EmitOrderUpdate)
|
||||
|
||||
if len(session.Notifiability.notifiers) > 0 {
|
||||
session.UserDataStream.OnDisconnect(func() {
|
||||
session.Notifiability.Notify("session %s user data stream disconnected", session.Name)
|
||||
})
|
||||
session.UserDataStream.OnConnect(func() {
|
||||
session.Notifiability.Notify("session %s user data stream connected", session.Name)
|
||||
})
|
||||
}
|
||||
|
||||
session.Account.BindStream(session.UserDataStream)
|
||||
|
||||
// if metrics mode is enabled, we bind the callbacks to update metrics
|
||||
|
|
|
@ -49,10 +49,10 @@ var defaultDialer = &websocket.Dialer{
|
|||
// - the re-connector calls connect() to create the new connection object, go to the 1 step.
|
||||
// When stream.Close() is called, a close message must be written to the websocket connection.
|
||||
|
||||
const readTimeout = 3 * time.Minute
|
||||
const writeTimeout = 15 * time.Second
|
||||
const pingInterval = readTimeout / 3
|
||||
const listenKeyKeepAliveInterval = 10 * time.Minute
|
||||
const readTimeout = 1 * time.Minute
|
||||
const writeTimeout = 5 * time.Second
|
||||
const pingInterval = readTimeout / 2
|
||||
const listenKeyKeepAliveInterval = 30 * time.Minute
|
||||
const reconnectCoolDownPeriod = 15 * time.Second
|
||||
|
||||
func init() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user