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
PollStrategyfor defining custom polling strategies. - Extension trait
PollStrategyExtfor ergonomic usage. PollContextstruct for passing contextual information to strategies.- Boxed trait object type
BoxedPollStrategyfor 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§
- Backoff
Config sleep - Backoff configuration for strategies
- Backoff
Strategy sleep - A polling strategy that applies exponential backoff to an inner interval strategy
- Future
Strategy - A polling strategy that uses a future factory to create futures for polling
- Interval
Strategy sleep - Interval-based polling strategy with optional backoff
- Multi
Strategy - 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
- Poll
Context - Context provided to the polling strategies Includes the worker context and a reference to the previous count of tasks received
- Race
Next - A stream that polls multiple streams, always returning the first ready item, and skipping one item from all other streams each round.
- Strategy
Builder - Builder for composing multiple polling strategies
- Stream
Strategy - A polling strategy that uses a provided stream
- Wrapper
Strategy - A polling strategy that wraps another strategy This is useful for coercing strategies
Traits§
- Poll
Strategy - A trait for different polling strategies All strategies can be combined in a race condition
- Poll
Strategy Ext - Extension trait for PollStrategy
Type Aliases§
- Boxed
Poll Strategy - A boxed poll strategy