pub struct WatchRegistry { /* private fields */ }Expand description
Watch registry — manages watcher registration (Arc-shareable).
Two independent DashMaps keep exact and prefix watchers separate so dispatch can use different lookup strategies for each without coupling.
Implementations§
Source§impl WatchRegistry
impl WatchRegistry
Sourcepub fn new(
watcher_buffer_size: usize,
unregister_tx: UnboundedSender<(u64, Bytes)>,
) -> Self
pub fn new( watcher_buffer_size: usize, unregister_tx: UnboundedSender<(u64, Bytes)>, ) -> Self
Create a new registry with no watcher count limit.
Sourcepub fn new_with_limits(
watcher_buffer_size: usize,
max_watcher_count: usize,
unregister_tx: UnboundedSender<(u64, Bytes)>,
) -> Self
pub fn new_with_limits( watcher_buffer_size: usize, max_watcher_count: usize, unregister_tx: UnboundedSender<(u64, Bytes)>, ) -> Self
Create a new registry with a hard watcher count cap.
register() and register_prefix() return WatchError::LimitExceeded
once max_watcher_count active watchers are registered.
Sourcepub fn register(
&self,
key: Bytes,
prev_kv: bool,
) -> Result<WatcherHandle, WatchError>
pub fn register( &self, key: Bytes, prev_kv: bool, ) -> Result<WatcherHandle, WatchError>
Register an exact-key watcher.
prev_kv: when true the server reads the old value before each write
and populates WatchEvent::prev_value. Only pays the read cost when
at least one watcher has prev_kv = true.
Returns WatchError::LimitExceeded if max_watcher_count is reached.
Sourcepub fn register_prefix(
&self,
prefix: Bytes,
prev_kv: bool,
) -> Result<WatcherHandle, WatchError>
pub fn register_prefix( &self, prefix: Bytes, prev_kv: bool, ) -> Result<WatcherHandle, WatchError>
Register a prefix watcher.
prefix must start with ‘/’ and end with ‘/’.
E.g. “/config/” watches all keys under /config/.
prev_kv: same semantics as register().
Returns WatchError::InvalidPrefix if format is wrong.
Returns WatchError::LimitExceeded if max_watcher_count is reached.
Sourcepub fn prev_kv_watcher_count(&self) -> usize
pub fn prev_kv_watcher_count(&self) -> usize
Number of active watchers that opted in to prev_kv.
Sourcepub fn prev_kv_watcher_count_arc(&self) -> Arc<AtomicUsize>
pub fn prev_kv_watcher_count_arc(&self) -> Arc<AtomicUsize>
Clone of the shared prev_kv counter Arc.
Pass this to DefaultStateMachineHandler so it can poll the live value
without holding a reference to the registry.
Auto Trait Implementations§
impl !Freeze for WatchRegistry
impl !RefUnwindSafe for WatchRegistry
impl Send for WatchRegistry
impl Sync for WatchRegistry
impl Unpin for WatchRegistry
impl UnsafeUnpin for WatchRegistry
impl UnwindSafe for WatchRegistry
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request