Skip to content

Commit

Permalink
increase subscription buffer size (#1989)
Browse files Browse the repository at this point in the history
  • Loading branch information
olegshmuelov authored Jan 19, 2025
1 parent b0b305d commit 4ba0e85
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions network/topics/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import (
pubsub "github.com/libp2p/go-libp2p-pubsub"
)

// Increased from the default (32) to reduce message drops caused by slow subscribers.
const subscriptionBufferSize = 128

type onTopicJoined func(ps *pubsub.PubSub, topic *pubsub.Topic)

type topicsContainer struct {
Expand Down Expand Up @@ -94,6 +97,8 @@ func (tc *topicsContainer) Subscribe(name string, opts ...pubsub.SubOpt) (*pubsu
return nil, err
}

opts = append(opts, pubsub.WithBufferSize(subscriptionBufferSize))

s, err := topic.Subscribe(opts...)
if err != nil {
return nil, err
Expand Down

0 comments on commit 4ba0e85

Please sign in to comment.