Skip to content

Commit 4b7cef9

Browse files
Jorropogammazero
authored andcommitted
feat(provider): adjustable MaxBatchSize limit (#544)
(cherry picked from commit 62b8ab7)
1 parent d337b7f commit 4b7cef9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

provider/reprovider.go

+11
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ func DatastorePrefix(k datastore.Key) Option {
183183
}
184184
}
185185

186+
// MaxBatchSize limit how big each batch is.
187+
// Some content routers like acceleratedDHTClient have sub linear scalling and
188+
// bigger sizes are thus faster per elements however smaller batch sizes can
189+
// limit memory usage spike.
190+
func MaxBatchSize(n uint) Option {
191+
return func(system *reprovider) error {
192+
system.maxReprovideBatchSize = n
193+
return nil
194+
}
195+
}
196+
186197
// ThroughputReport will fire the callback synchronously once at least limit
187198
// multihashes have been advertised, it will then wait until a new set of at least
188199
// limit multihashes has been advertised.

0 commit comments

Comments
 (0)