Skip to main content

PromotionStore

Trait PromotionStore 

Source
pub trait PromotionStore:
    Send
    + Sync
    + Debug {
    // Required methods
    fn load<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        now: Instant,
    ) -> Pin<Box<dyn Future<Output = Option<Pin>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn store<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        pin: Pin,
        now: Instant,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Where promotion state lives.

Same seam as the verified cache, for the same reason: in-process state fragments behind a load balancer. A session that escalated on replica A starts cold on replica B, so the escalation tax this feature exists to remove is paid again on roughly (N-1)/N of turns.

Concurrent turns of one session race. record is a read-modify-write, and two replicas handling turns simultaneously can lose one increment — last write wins. That is deliberate rather than overlooked: the cost is a promotion arriving one turn late, which is one extra cheap-rung call. The gate still verifies whatever is served, so the race cannot affect correctness, and a Lua script or WATCH loop to remove it would add real complexity to an optimisation.

Required Methods§

Source

fn load<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, now: Instant, ) -> Pin<Box<dyn Future<Output = Option<Pin>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read a session’s pin, if one is live.

Source

fn store<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, pin: Pin, now: Instant, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Write a session’s pin.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§