pub struct FallbackStrategy { /* private fields */ }Expand description
Strategy that tries multiple generators in order, using the first success.
This implements a fallback chain: try the primary strategy first, and if it
returns None, try the next strategy, and so on. Useful for providing
fine-grained ordering when possible, with coarser fallbacks.
§Example
use queue_runtime::sessions::{FallbackStrategy, SingleFieldStrategy, CompositeKeyStrategy};
// Try specific entity ID first, fall back to tenant-level ordering
let primary = SingleFieldStrategy::new("entity_id", Some("entity"));
let fallback = SingleFieldStrategy::new("tenant_id", Some("tenant"));
let strategy = FallbackStrategy::new(vec![
Box::new(primary),
Box::new(fallback),
]);Implementations§
Source§impl FallbackStrategy
impl FallbackStrategy
Sourcepub fn new(strategies: Vec<Box<dyn SessionKeyGenerator>>) -> Self
pub fn new(strategies: Vec<Box<dyn SessionKeyGenerator>>) -> Self
Create a new fallback strategy with ordered generators.
§Arguments
strategies- Ordered list of generators to try
§Example
use queue_runtime::sessions::{FallbackStrategy, SingleFieldStrategy, NoOrderingStrategy};
let strategy = FallbackStrategy::new(vec![
Box::new(SingleFieldStrategy::new("user_id", Some("user"))),
Box::new(NoOrderingStrategy), // Ultimate fallback: no ordering
]);Trait Implementations§
Source§impl SessionKeyGenerator for FallbackStrategy
impl SessionKeyGenerator for FallbackStrategy
Source§fn generate_key(&self, extractor: &dyn SessionKeyExtractor) -> Option<SessionId>
fn generate_key(&self, extractor: &dyn SessionKeyExtractor) -> Option<SessionId>
Generate a session key for the given message. Read more
Auto Trait Implementations§
impl Freeze for FallbackStrategy
impl !RefUnwindSafe for FallbackStrategy
impl Send for FallbackStrategy
impl Sync for FallbackStrategy
impl Unpin for FallbackStrategy
impl UnsafeUnpin for FallbackStrategy
impl !UnwindSafe for FallbackStrategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more