Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions providers/base/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"go.uber.org/zap"

"github.com/skip-mev/connect/v2/pkg/slices"
providermetrics "github.com/skip-mev/connect/v2/providers/base/metrics"
providertypes "github.com/skip-mev/connect/v2/providers/types"
)
Expand Down Expand Up @@ -85,23 +86,8 @@ func (p *Provider[K, V]) startMultiplexWebsocket(ctx context.Context) error {
if maxSubsPerConn > 0 {
// case where we will split ID's across sub handlers
numSubHandlers := int(math.Ceil(float64(len(ids)) / float64(maxSubsPerConn)))
p.logger.Debug("setting number of web socket handlers for provider", zap.Int("sub_handlers", numSubHandlers))
wg.SetLimit(numSubHandlers)

// split ids
for i := 0; i < numSubHandlers; i++ {
start := i * maxSubsPerConn

// Copy the IDs over.
subIDs := make([]K, 0)
if end := start + maxSubsPerConn; end >= len(ids) {
subIDs = append(subIDs, ids[start:]...)
} else {
subIDs = append(subIDs, ids[start:end]...)
}

subTasks = append(subTasks, subIDs)
}
subTasks = slices.Chunk(ids, maxSubsPerConn)
} else {
// case where there is 1 sub handler
subTasks = append(subTasks, ids)
Expand All @@ -110,14 +96,6 @@ func (p *Provider[K, V]) startMultiplexWebsocket(ctx context.Context) error {

for _, subIDs := range subTasks {
wg.Go(p.startWebSocket(ctx, subIDs))

select {
case <-time.After(p.wsCfg.HandshakeTimeout):
p.logger.Debug("handshake timeout reached")
case <-ctx.Done():
p.logger.Debug("context done")
return wg.Wait()
}
}

// Wait for all the sub handlers to finish.
Expand Down