pub struct SubscriberIndex { /* private fields */ }Expand description
A global bucket -> snapshot index.
Read path: lock-free load (ArcSwap) Write path: atomic replacement after building a new snapshot
Implementations§
Source§impl SubscriberIndex
impl SubscriberIndex
Sourcepub fn new(empty_rules: Arc<DynRulesContainer>) -> Self
pub fn new(empty_rules: Arc<DynRulesContainer>) -> Self
Create a new SubscriberIndex.
§Arguments
empty_rules- An Arc to an empty rules container used for empty snapshots
Returns a new instance of SubscriberIndex.
Sourcepub fn load_snapshot(&self, bucket: &str) -> BucketSnapshotRef
pub fn load_snapshot(&self, bucket: &str) -> BucketSnapshotRef
Get the current snapshot of a bucket. If it does not exist, return empty snapshot.
§Arguments
bucket- The name of the bucket to load.
Returns the snapshot reference for the specified bucket.
Sourcepub fn has_subscriber(&self, bucket: &str, event: &EventName) -> bool
pub fn has_subscriber(&self, bucket: &str, event: &EventName) -> bool
Quickly determine whether the bucket has a subscription to an event. This judgment can be consistent with subsequent rule matching when reading the same snapshot.
§Arguments
bucket- The name of the bucket to check.event- The event name to check for subscriptions.
Returns true if there are subscribers for the event, false otherwise.
Sourcepub fn store_snapshot(
&self,
bucket: &str,
new_snapshot: BucketRulesSnapshot<DynRulesContainer>,
)
pub fn store_snapshot( &self, bucket: &str, new_snapshot: BucketRulesSnapshot<DynRulesContainer>, )
Atomically update a bucket’s snapshot (whole package replacement).
- The caller first builds the complete
BucketRulesSnapshot(including event_mask and rules). - This method ensures that the read path will not observe intermediate states.
§Arguments
bucket- The name of the bucket to update.new_snapshot- The new snapshot to store for the bucket.
Sourcepub fn clear_bucket(&self, bucket: &str)
pub fn clear_bucket(&self, bucket: &str)
Delete the bucket’s subscription view (make it empty).
§Arguments
bucket- The name of the bucket to clear.
Trait Implementations§
Source§impl Debug for SubscriberIndex
Avoid deriving fields that do not support Debug
impl Debug for SubscriberIndex
Avoid deriving fields that do not support Debug
Auto Trait Implementations§
impl !RefUnwindSafe for SubscriberIndex
impl !UnwindSafe for SubscriberIndex
impl Freeze for SubscriberIndex
impl Send for SubscriberIndex
impl Sync for SubscriberIndex
impl Unpin for SubscriberIndex
impl UnsafeUnpin for SubscriberIndex
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestCreates a shared type from an unshared type.