[][src]Trait krill::commons::eventsourcing::KeyStore

pub trait KeyStore {
    type Key: From<CommandKey> + From<&'static CommandKey> + TryInto<CommandKey>;
    fn get_version(&self) -> Result<KeyStoreVersion, KeyStoreError>;
fn set_version(
        &self,
        version: &KeyStoreVersion
    ) -> Result<(), KeyStoreError>;
fn key_for_info() -> Self::Key;
fn key_for_snapshot() -> Self::Key;
fn key_for_event(version: u64) -> Self::Key;
fn key_for_command<S: WithStorableDetails>(
        command: &StoredCommand<S>
    ) -> CommandKey;
fn keys(&self, id: &Handle, matching: &str) -> Vec<Self::Key>;
fn keys_ascending(&self, id: &Handle, matching: &str) -> Vec<Self::Key>;
fn command_keys_ascending(
        &self,
        id: &Handle,
        crit: &CommandHistoryCriteria
    ) -> Vec<CommandKey>;
fn has_key(&self, id: &Handle, key: &Self::Key) -> bool;
fn has_aggregate(&self, id: &Handle) -> bool;
fn aggregates(&self) -> Vec<Handle>;
fn store<V: Any + Serialize>(
        &self,
        id: &Handle,
        key: &Self::Key,
        value: &V
    ) -> Result<(), KeyStoreError>;
fn get<V: Any + Storable>(
        &self,
        id: &Handle,
        key: &Self::Key
    ) -> Result<Option<V>, KeyStoreError>;
fn drop(&self, id: &Handle, key: &Self::Key) -> Result<(), KeyStoreError>;
fn get_event<V: Event>(
        &self,
        id: &Handle,
        version: u64
    ) -> Result<Option<V>, KeyStoreError>;
fn store_event<V: Event>(&self, event: &V) -> Result<(), KeyStoreError>;
fn store_command<S: WithStorableDetails>(
        &self,
        command: StoredCommand<S>
    ) -> Result<(), KeyStoreError>;
fn get_aggregate<V: Aggregate>(
        &self,
        id: &Handle
    ) -> Result<Option<V>, KeyStoreError>;
fn store_snapshot<V: Aggregate>(
        &self,
        id: &Handle,
        aggregate: &V
    ) -> Result<(), KeyStoreError>; fn get_info(&self, id: &Handle) -> Result<StoredValueInfo, KeyStoreError> { ... }
fn save_info(
        &self,
        id: &Handle,
        info: &StoredValueInfo
    ) -> Result<(), KeyStoreError> { ... }
fn command_history<A: Aggregate>(
        &self,
        id: &Handle,
        crit: CommandHistoryCriteria
    ) -> Result<CommandHistory, KeyStoreError> { ... } }

Generic KeyStore for AggregateManager

Associated Types

Loading content...

Required methods

fn get_version(&self) -> Result<KeyStoreVersion, KeyStoreError>

fn set_version(&self, version: &KeyStoreVersion) -> Result<(), KeyStoreError>

fn key_for_info() -> Self::Key

fn key_for_snapshot() -> Self::Key

fn key_for_event(version: u64) -> Self::Key

fn key_for_command<S: WithStorableDetails>(
    command: &StoredCommand<S>
) -> CommandKey

fn keys(&self, id: &Handle, matching: &str) -> Vec<Self::Key>

Returns all keys for a Handle in the store, matching a &str

fn keys_ascending(&self, id: &Handle, matching: &str) -> Vec<Self::Key>

Returns all keys for a Handle in the store, matching a &str, sorted ascending

fn command_keys_ascending(
    &self,
    id: &Handle,
    crit: &CommandHistoryCriteria
) -> Vec<CommandKey>

fn has_key(&self, id: &Handle, key: &Self::Key) -> bool

Returns whether a key already exists.

fn has_aggregate(&self, id: &Handle) -> bool

fn aggregates(&self) -> Vec<Handle>

fn store<V: Any + Serialize>(
    &self,
    id: &Handle,
    key: &Self::Key,
    value: &V
) -> Result<(), KeyStoreError>

Write or overwrite the value for an existing. Must not throw an error if the key already exists.

fn get<V: Any + Storable>(
    &self,
    id: &Handle,
    key: &Self::Key
) -> Result<Option<V>, KeyStoreError>

Get the value for this key, if any exists.

fn drop(&self, id: &Handle, key: &Self::Key) -> Result<(), KeyStoreError>

Drop the value for this key

fn get_event<V: Event>(
    &self,
    id: &Handle,
    version: u64
) -> Result<Option<V>, KeyStoreError>

Get the value for this key, if any exists.

fn store_event<V: Event>(&self, event: &V) -> Result<(), KeyStoreError>

MUST check if the event already exists and return an error if it does.

fn store_command<S: WithStorableDetails>(
    &self,
    command: StoredCommand<S>
) -> Result<(), KeyStoreError>

fn get_aggregate<V: Aggregate>(
    &self,
    id: &Handle
) -> Result<Option<V>, KeyStoreError>

Get the latest aggregate

fn store_snapshot<V: Aggregate>(
    &self,
    id: &Handle,
    aggregate: &V
) -> Result<(), KeyStoreError>

Saves the latest snapshot - overwrites any previous snapshot.

Loading content...

Provided methods

fn get_info(&self, id: &Handle) -> Result<StoredValueInfo, KeyStoreError>

fn save_info(
    &self,
    id: &Handle,
    info: &StoredValueInfo
) -> Result<(), KeyStoreError>

fn command_history<A: Aggregate>(
    &self,
    id: &Handle,
    crit: CommandHistoryCriteria
) -> Result<CommandHistory, KeyStoreError>

Find all commands that fit the criteria and return history

Loading content...

Implementors

impl KeyStore for DiskKeyStore[src]

type Key = PathBuf

fn get_event<V: Event>(
    &self,
    id: &Handle,
    version: u64
) -> Result<Option<V>, KeyStoreError>
[src]

Get the value for this key, if any exists.

Loading content...