Module poll_strategy

Module poll_strategy 

Source
Expand description

Polling strategies for backends.

This module provides abstractions and implementations for different polling strategies used by backends to determine when to poll for new tasks. Strategies can be combined, customized, and extended to suit various workload requirements.

§Features

  • Trait PollStrategy for defining custom polling strategies.
  • Extension trait PollStrategyExt for ergonomic usage.
  • PollContext struct for passing contextual information to strategies.
  • Boxed trait object type BoxedPollStrategy for dynamic dispatch.
  • Built-in strategies and combinators.

§Usage

Implement the PollStrategy trait for your custom strategy, or use the provided strategies and combinators. Use PollContext to access worker state and previous task counts.

See submodules for available strategies and builder utilities.

Structs§

BackoffConfigsleep
Backoff configuration for strategies
BackoffStrategysleep
A polling strategy that applies exponential backoff to an inner interval strategy
FutureStrategy
A polling strategy that uses a future factory to create futures for polling
IntervalStrategysleep
Interval-based polling strategy with optional backoff
MultiStrategy
A polling strategy that combines multiple strategies The strategies are executed in the order they were added to the builder In case of multiple strategies being ready at the same time, the first one added will be chosen
PollContext
Context provided to the polling strategies Includes the worker context and a reference to the previous count of tasks received
RaceNext
A stream that polls multiple streams, always returning the first ready item, and skipping one item from all other streams each round.
StrategyBuilder
Builder for composing multiple polling strategies
StreamStrategy
A polling strategy that uses a provided stream
WrapperStrategy
A polling strategy that wraps another strategy This is useful for coercing strategies

Traits§

PollStrategy
A trait for different polling strategies All strategies can be combined in a race condition
PollStrategyExt
Extension trait for PollStrategy

Type Aliases§

BoxedPollStrategy
A boxed poll strategy