Struct fluvio_controlplane_metadata::store::LocalStore
source · pub struct LocalStore<S, C>where
S: Spec,
C: MetadataItem,{ /* private fields */ }
Expand description
Idempotent local memory cache of meta objects.
There are only 2 write operations are permitted: sync and apply changes which are idempotent.
For read, read guards are provided which provide hash map API using deref.
Hash values are wrapped in EpochCounter. EpochCounter is also deref.
Using async lock to ensure read/write are thread safe.
Implementations
sourceimpl<S, C> LocalStore<S, C>where
S: Spec,
C: MetadataItem,
impl<S, C> LocalStore<S, C>where
S: Spec,
C: MetadataItem,
sourcepub fn bulk_new<N>(objects: Vec<N, Global>) -> LocalStore<S, C>where
N: Into<MetadataStoreObject<S, C>>,
pub fn bulk_new<N>(objects: Vec<N, Global>) -> LocalStore<S, C>where
N: Into<MetadataStoreObject<S, C>>,
initialize local stores with list of metadata objects
create arc wrapper
sourcepub async fn read<'a>(
&self
) -> impl Future<Output = RwLockReadGuard<'_, DualEpochMap<<S as Spec>::IndexKey, MetadataStoreObject<S, C>>>>
pub async fn read<'a>(
&self
) -> impl Future<Output = RwLockReadGuard<'_, DualEpochMap<<S as Spec>::IndexKey, MetadataStoreObject<S, C>>>>
Read guard
sourcepub fn init_epoch(&self) -> DualEpochCounter<()>
pub fn init_epoch(&self) -> DualEpochCounter<()>
initial epoch that should be used store will always have epoch greater than init_epoch if there are any changes
sourcepub async fn value<K>(
&self,
key: &K
) -> impl Future<Output = Option<DualEpochCounter<MetadataStoreObject<S, C>>>>where
<S as Spec>::IndexKey: Borrow<K>,
K: Eq + Hash + ?Sized,
pub async fn value<K>(
&self,
key: &K
) -> impl Future<Output = Option<DualEpochCounter<MetadataStoreObject<S, C>>>>where
<S as Spec>::IndexKey: Borrow<K>,
K: Eq + Hash + ?Sized,
copy of the value
sourcepub async fn spec<K>(&self, key: &K) -> impl Future<Output = Option<S>>where
<S as Spec>::IndexKey: Borrow<K>,
K: Eq + Hash + ?Sized,
pub async fn spec<K>(&self, key: &K) -> impl Future<Output = Option<S>>where
<S as Spec>::IndexKey: Borrow<K>,
K: Eq + Hash + ?Sized,
copy spec
sourcepub async fn find_and_do<K, F>(
&self,
key: &K,
func: F
) -> impl Future<Output = Option<()>>where
F: FnMut(&MetadataStoreObject<S, C>),
K: Eq + Hash,
<S as Spec>::IndexKey: Borrow<K>,
pub async fn find_and_do<K, F>(
&self,
key: &K,
func: F
) -> impl Future<Output = Option<()>>where
F: FnMut(&MetadataStoreObject<S, C>),
K: Eq + Hash,
<S as Spec>::IndexKey: Borrow<K>,
iterate over entry
pub async fn contains_key<K>(&self, key: &K) -> impl Future<Output = bool>where
<S as Spec>::IndexKey: Borrow<K>,
K: Eq + Hash + ?Sized,
pub async fn count(&self) -> impl Future<Output = usize>
pub async fn clone_specs(&self) -> impl Future<Output = Vec<S, Global>>
pub async fn clone_keys(
&self
) -> impl Future<Output = Vec<<S as Spec>::IndexKey, Global>>
pub async fn clone_values(
&self
) -> impl Future<Output = Vec<MetadataStoreObject<S, C>, Global>>
pub fn event_publisher(&self) -> &EventPublisher
sourcepub fn change_listener(self: &Arc<LocalStore<S, C>>) -> ChangeListener<S, C>
pub fn change_listener(self: &Arc<LocalStore<S, C>>) -> ChangeListener<S, C>
create new change listener
sourcepub async fn wait_for_first_change(
self: &Arc<LocalStore<S, C>>
) -> impl Future<Output = ()>
pub async fn wait_for_first_change(
self: &Arc<LocalStore<S, C>>
) -> impl Future<Output = ()>
returns once there is at least one change recorded by the the event_publisher
sourceimpl<S, C> LocalStore<S, C>where
S: Spec + PartialEq<S>,
<S as Spec>::Status: PartialEq<<S as Spec>::Status>,
<S as Spec>::IndexKey: Display,
C: MetadataItem + PartialEq<C>,
impl<S, C> LocalStore<S, C>where
S: Spec + PartialEq<S>,
<S as Spec>::Status: PartialEq<<S as Spec>::Status>,
<S as Spec>::IndexKey: Display,
C: MetadataItem + PartialEq<C>,
sourcepub async fn sync_all(
&self,
incoming_changes: Vec<MetadataStoreObject<S, C>, Global>
) -> impl Future<Output = SyncStatus>
pub async fn sync_all(
&self,
incoming_changes: Vec<MetadataStoreObject<S, C>, Global>
) -> impl Future<Output = SyncStatus>
sync with incoming changes as source of truth. any objects not in incoming list will be deleted after sync operation, prior history will be removed and any subsequent change query will return full list instead of changes
sourcepub async fn apply_changes(
&self,
changes: Vec<LSUpdate<S, C>, Global>
) -> impl Future<Output = Option<SyncStatus>>
pub async fn apply_changes(
&self,
changes: Vec<LSUpdate<S, C>, Global>
) -> impl Future<Output = Option<SyncStatus>>
apply changes to this store if item doesn’t exit, it will be treated as add if item exist but different, it will be treated as updated epoch will be only incremented if there are actual changes which means this is idempotent operations. same add result in only 1 single epoch increase.