Struct zookeeper_async::recipes::cache::PathChildrenCache [−][src]
A Path Cache is used to watch a znode.
A utility that attempts to keep all data from all children of a ZK path locally cached. This will watch the ZK path; whenever a child is added, updated or removed, the Path Cache will change its state to contain the current set of children, the children's data and the children's state. You can register a listener that will get notified when changes occur.
Note
It is not possible to stay transactionally in sync. Users of this class must be prepared for false-positives and false-negatives. Additionally, always use the version number when updating data to avoid overwriting another process's change.
Implementations
impl PathChildrenCache
[src]
pub async fn new(zk: Arc<ZooKeeper>, path: &str) -> ZkResult<PathChildrenCache>
[src]
Create a new cache instance watching path
. If path
does not exist, it will be created
(see ZooKeeperExt::ensure_path
).
Note
After creating the instance, you must call start
.
pub async fn get_current_data(&self) -> Data
[src]
Return the current data. There are no guarantees of accuracy. This is merely the most recent view of the data.
pub async fn clear(&self)
[src]
pub fn start(&mut self) -> ZkResult<()>
[src]
Start the cache. The cache is not started automatically. You must call this method.
pub fn add_listener<Listener: Fn(PathChildrenCacheEvent) + Send + 'static>(
&self,
subscriber: Listener
) -> Subscription
[src]
&self,
subscriber: Listener
) -> Subscription
pub fn remove_listener(&self, sub: Subscription)
[src]
Auto Trait Implementations
impl !RefUnwindSafe for PathChildrenCache
[src]
impl Send for PathChildrenCache
[src]
impl Sync for PathChildrenCache
[src]
impl Unpin for PathChildrenCache
[src]
impl !UnwindSafe for PathChildrenCache
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,