Refactor Binance Futures Websocket: enhance configuration management, implement shard handling, and improve subscription logic

This commit is contained in:
2025-09-17 10:57:21 +00:00
parent 78c7632394
commit 7109acc207
8 changed files with 1255 additions and 104 deletions

View File

@@ -0,0 +1,21 @@
package ws
import "regexp"
var (
reAggTrade = regexp.MustCompile(`^[a-z0-9]+@aggTrade$`)
reTrade = regexp.MustCompile(`^[a-z0-9]+@trade$`)
reMarkPrice = regexp.MustCompile(`^[a-z0-9]+@markPrice(@1s)?$`)
reKline = regexp.MustCompile(`^[a-z0-9]+@kline_(1s|1m|3m|5m|15m|30m|1h|2h|4h|6h|8h|12h|1d|3d|1w|1M)$`)
reBookTicker = regexp.MustCompile(`^[a-z0-9]+@bookTicker$`)
reDepth = regexp.MustCompile(`^[a-z0-9]+@depth(@100ms)?$`)
)
func IsValidSubject(s string) bool {
return reAggTrade.MatchString(s) ||
reTrade.MatchString(s) ||
reMarkPrice.MatchString(s) ||
reKline.MatchString(s) ||
reBookTicker.MatchString(s) ||
reDepth.MatchString(s)
}