Begun redesign of binance futures websocket. Added test provider for testing purposes.

This commit is contained in:
2025-09-11 08:29:12 +00:00
parent e56bb210f8
commit 924187b2f5
10 changed files with 261 additions and 451 deletions

View File

@@ -0,0 +1,52 @@
package ws
import (
"fmt"
"time"
"github.com/google/uuid"
"gitlab.michelsen.id/phillmichelsen/tessera/services/data_service/internal/domain"
)
type BinanceFutures struct {
cfg config
shards map[uuid.UUID]*shard
streamAssignments map[string]*shard
}
type config struct {
Endpoint string
MaxStreamsPerShard uint8
BatchInterval time.Duration
}
func NewBinanceFuturesWebsocket(cfg config) *BinanceFutures {
return &BinanceFutures{
cfg: cfg,
shards: make(map[uuid.UUID]*shard),
}
}
func (b *BinanceFutures) Start() error {
return nil
}
func (b *BinanceFutures) Stop() {
return
}
func (b *BinanceFutures) Subscribe(subject string) <-chan error {
return nil
}
func (b *BinanceFutures) Unsubscribe(subject string) <-chan error {
return nil
}
func (b *BinanceFutures) Fetch(subject string) (domain.Message, error) {
return domain.Message{}, fmt.Errorf("fetch not supported by provider")
}
func (b *BinanceFutures) GetActiveStreams() []string { return nil }
func (b *BinanceFutures) IsStreamActive(key string) bool { return false }
func (b *BinanceFutures) IsValidSubject(key string, isFetch bool) bool { return false }

View File

@@ -0,0 +1,12 @@
package ws
import (
"github.com/coder/websocket"
"github.com/google/uuid"
)
type shard struct {
ID uuid.UUID
conn websocket.Conn
activeStreams []string
}