pub struct Singleflight { /* private fields */ }Expand description
Singleflight coalescing layer.
Tracks in-flight queries by key. Concurrent identical queries share results.
Implementations§
Source§impl Singleflight
impl Singleflight
Sourcepub fn try_join(&self, key: u64) -> FlightResult
pub fn try_join(&self, key: u64) -> FlightResult
Try to join an in-flight query group, or become the leader.
key should be a hash of (sql_hash, parameter bytes).
Sourcepub fn wait_for_result(
state: &FlightState,
) -> Option<Arc<Result<Arc<OwnedResultSnapshot>, BsqlError>>>
pub fn wait_for_result( state: &FlightState, ) -> Option<Arc<Result<Arc<OwnedResultSnapshot>, BsqlError>>>
Wait for a flight result as a follower.
Blocks until the leader calls complete() or is dropped. Returns
None if the leader was dropped without completing (e.g., panic).
Sourcepub fn compute_key(sql_hash: u64, params: &[&(dyn Encode + Sync)]) -> u64
pub fn compute_key(sql_hash: u64, params: &[&(dyn Encode + Sync)]) -> u64
Compute a singleflight key from sql_hash and parameter data.
Uses rapidhash to combine the sql_hash with a hash of all parameter bytes (including actual encoded values). Two queries with the same SQL and same parameter values produce the same key.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Singleflight
impl RefUnwindSafe for Singleflight
impl Send for Singleflight
impl Sync for Singleflight
impl Unpin for Singleflight
impl UnsafeUnpin for Singleflight
impl UnwindSafe for Singleflight
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