Skip to main content

Module transfer

Module transfer 

Source
Expand description

Transfer configuration, rate limiting, and bounded-concurrency driver.

This module is the foundation for concurrent object transfers and bandwidth limiting. It provides:

  • TransferConfig — how many objects to transfer in parallel and an optional aggregate byte-rate cap.
  • RateLimiter — a zero-dependency async token bucket built on tokio::time, shareable across tasks via Arc.
  • run_concurrent — a generic bounded-concurrency driver that runs up to concurrency async operations in flight and returns the first error.

Nothing here changes the existing (sequential) push / fetch loops yet; the stores merely carry a TransferConfig so later gates can wire these primitives into their transfer loops.

Structs§

BlockingRateLimiter
A synchronous token-bucket rate limiter for the store-to-store sync path.
RateLimiter
An async token-bucket rate limiter that throttles aggregate transfer throughput.
TransferConfig
Configuration for object transfers: how many to run in parallel, an optional aggregate byte-rate cap, and whether to tune those adaptively.

Enums§

AdaptivePolicy
Whether (and how) a transfer adaptively tunes its concurrency / byte-rate.

Functions§

classify_error
Classifies a StoreError for the adaptive controller’s congestion signal.
run_adaptive
Runs op over items with the in-flight window sized to gate.ceiling() but the effective concurrency gated to the gate’s live limit: each item acquires a GatePermit before op runs and holds it until op completes. This is the adaptive sibling of run_concurrent: a background tick driver resizes the gate live, so the number of simultaneously-running ops tracks the controller’s limit while the buffer window stays at the ceiling.
run_concurrent
Runs op over items with at most concurrency operations in flight, collecting their results in completion-independent order and returning the first error encountered (remaining in-flight work is cancelled).