Struct fluvio_stream_model::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§

source§

impl<S, C> LocalStore<S, C>
where S: Spec, C: MetadataItem,

source

pub fn bulk_new(objects: Vec<impl Into<MetadataStoreObject<S, C>>>) -> Self

initialize local stores with list of metadata objects

source

pub fn new_shared() -> Arc<Self>

create arc wrapper

source

pub async fn read<'a>( &self ) -> RwLockReadGuard<'_, DualEpochMap<S::IndexKey, MetadataStoreObject<S, C>>>

Read guard

source

pub async fn epoch(&self) -> i64

current epoch

source

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

source

pub async fn value<K>( &self, key: &K ) -> Option<DualEpochCounter<MetadataStoreObject<S, C>>>
where S::IndexKey: Borrow<K>, K: ?Sized + Eq + Hash,

copy of the value

source

pub async fn spec<K>(&self, key: &K) -> Option<S>
where S::IndexKey: Borrow<K>, K: ?Sized + Eq + Hash,

copy spec

source

pub async fn find_and_do<K, F>(&self, key: &K, func: F) -> Option<()>
where F: FnMut(&MetadataStoreObject<S, C>), K: Eq + Hash, S::IndexKey: Borrow<K>,

iterate over entry

source

pub async fn contains_key<K>(&self, key: &K) -> bool
where S::IndexKey: Borrow<K>, K: ?Sized + Eq + Hash,

source

pub async fn count(&self) -> usize

source

pub async fn clone_specs(&self) -> Vec<S>

source

pub async fn clone_keys(&self) -> Vec<S::IndexKey>

source

pub async fn clone_values(&self) -> Vec<MetadataStoreObject<S, C>>

source

pub fn event_publisher(&self) -> &EventPublisher

source

pub fn change_listener(self: &Arc<Self>) -> ChangeListener<S, C>

create new change listener

source

pub async fn wait_for_first_change(self: &Arc<Self>)

returns once there is at least one change recorded by the the event_publisher

source§

impl<S, C> LocalStore<S, C>
where S: Spec, C: MetadataItem,

source

pub async fn sync_all( &self, incoming_changes: Vec<MetadataStoreObject<S, C>> ) -> 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

source

pub async fn apply_changes( &self, changes: Vec<LSUpdate<S, C>> ) -> 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.

Trait Implementations§

source§

impl<S, C> Debug for LocalStore<S, C>
where S: Spec + Debug, C: MetadataItem + Debug, S::IndexKey: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<S, C> Default for LocalStore<S, C>
where S: Spec, C: MetadataItem,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<S, C> Display for LocalStore<S, C>
where S: Spec, C: MetadataItem,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S, C> !Freeze for LocalStore<S, C>

§

impl<S, C> !RefUnwindSafe for LocalStore<S, C>

§

impl<S, C> Send for LocalStore<S, C>

§

impl<S, C> Sync for LocalStore<S, C>

§

impl<S, C> Unpin for LocalStore<S, C>
where <S as Spec>::IndexKey: Unpin, S: Unpin, <S as Spec>::Status: Unpin, C: Unpin,

§

impl<S, C> UnwindSafe for LocalStore<S, C>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more