mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
implement UnixMilli in the util package
This commit is contained in:
parent
d433c7f5b1
commit
ed6f400161
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"github.com/c9s/bbgo/pkg/exchange/kucoin/kucoinapi"
|
||||
"github.com/c9s/bbgo/pkg/types"
|
||||
"github.com/c9s/bbgo/pkg/util"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -390,7 +391,7 @@ type WebSocketConnector interface {
|
|||
}
|
||||
|
||||
func ping(ctx context.Context, w WebSocketConnector, interval time.Duration) {
|
||||
log.Infof("starting ping worker with interval %s", interval)
|
||||
log.Infof("starting websocket ping worker with interval %s", interval)
|
||||
|
||||
pingTicker := time.NewTicker(interval)
|
||||
defer pingTicker.Stop()
|
||||
|
@ -406,7 +407,7 @@ func ping(ctx context.Context, w WebSocketConnector, interval time.Duration) {
|
|||
conn := w.Conn()
|
||||
|
||||
if err := conn.WriteJSON(WebSocketCommand{
|
||||
Id: time.Now().UnixNano() / int64(time.Millisecond),
|
||||
Id: util.UnixMilli(),
|
||||
Type: "ping",
|
||||
}); err != nil {
|
||||
log.WithError(err).Error("websocket ping error", err)
|
||||
|
|
|
@ -18,3 +18,7 @@ func BeginningOfTheDay(t time.Time) time.Time {
|
|||
func Over24Hours(since time.Time) bool {
|
||||
return time.Since(since) >= 24 * time.Hour
|
||||
}
|
||||
|
||||
func UnixMilli() int64 {
|
||||
return time.Now().UnixNano() / int64(time.Millisecond)
|
||||
}
|
Loading…
Reference in New Issue
Block a user