Skip to main content

IdempotencyKeyStore

Trait IdempotencyKeyStore 

Source
pub trait IdempotencyKeyStore: Send + Sync {
    // Required methods
    fn store_result<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 IdempotencyKey,
        result: &'life2 ExtractionResult,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_result<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 IdempotencyKey,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ExtractionResult>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_result<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 IdempotencyKey,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn clear_all<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Port for tracking idempotency keys and results

Prevents duplicate extractions by caching results per idempotency key.

§Example

use stygian_plugin::ports::IdempotencyKeyStore;
use stygian_plugin::domain::{IdempotencyKey, ExtractionResult};
let key = IdempotencyKey::new();
let result = ExtractionResult::new(key);
store.store_result(&key, &result).await?;
let retrieved = store.get_result(&key).await?;

Required Methods§

Source

fn store_result<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 IdempotencyKey, result: &'life2 ExtractionResult, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Store an extraction result under an idempotency key

Source

fn get_result<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 IdempotencyKey, ) -> Pin<Box<dyn Future<Output = Result<Option<ExtractionResult>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve a cached result by idempotency key

Source

fn delete_result<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 IdempotencyKey, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete an old result (cleanup)

Source

fn clear_all<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clear all results (for testing)

Implementors§