Skip to main content

ProcessStore

Trait ProcessStore 

Source
pub trait ProcessStore: Send + Sync {
    // Required methods
    fn put<'life0, 'async_trait>(
        &'life0 self,
        meta: ProcessMeta,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        pid: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ProcessMeta>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list<'life0, 'life1, 'async_trait>(
        &'life0 self,
        filter: &'life1 ProcessFilter,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ProcessMeta>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn set_wake<'life0, 'life1, 'async_trait>(
        &'life0 self,
        pid: &'life1 str,
        wake: Option<WakeSet>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn set_queue<'life0, 'life1, 'async_trait>(
        &'life0 self,
        pid: &'life1 str,
        queue: QueueClass,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        pid: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn set_suspend_requested<'life0, 'life1, 'async_trait>(
        &'life0 self,
        pid: &'life1 str,
        requested: bool,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn add_spend<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        pid: &'life1 str,
        partition: &'life2 PartitionId,
        day: NaiveDate,
        delta: SpendDelta,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn spend<'life0, 'life1, 'async_trait>(
        &'life0 self,
        scope: &'life1 SpendScope,
        from: NaiveDate,
        to_inclusive: NaiveDate,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn usage<'life0, 'life1, 'async_trait>(
        &'life0 self,
        scope: &'life1 SpendScope,
        from: NaiveDate,
        to_inclusive: NaiveDate,
    ) -> Pin<Box<dyn Future<Output = Result<UsageTotals>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

The kernel’s side table of process metadata, keyed by run id (spec 3.2 §7.3, §6 D-2).

RunRecord has no metadata field, so the kernel keeps what the run store does not here instead of changing the run store’s schema across six backends. Rows of runs the run store has pruned are deleted with delete.

§Example

use adk_kernel::{InMemoryProcessStore, ProcessKind, ProcessMeta, ProcessStore, QueueClass};

let store = InMemoryProcessStore::new();
store.put(ProcessMeta::new("run-1", QueueClass::Background, ProcessKind::Goal)).await?;
store.set_queue("run-1", QueueClass::Interactive).await?;
assert_eq!(store.get("run-1").await?.unwrap().queue, QueueClass::Interactive);

Required Methods§

Source

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

Inserts meta, or replaces the row with the same pid.

§Errors

Returns KernelError::Store when the backend fails.

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, pid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<ProcessMeta>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The row of pid, or None.

§Errors

Returns KernelError::Store when the backend fails.

Source

fn list<'life0, 'life1, 'async_trait>( &'life0 self, filter: &'life1 ProcessFilter, ) -> Pin<Box<dyn Future<Output = Result<Vec<ProcessMeta>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The rows filter selects by partition, queue, parent and pending suspension request, ordered by pid, at most filter.limit. filter.states is a run-store field and is applied by ProcessTable::ps, not here.

§Errors

Returns KernelError::Store when the backend fails.

Source

fn set_wake<'life0, 'life1, 'async_trait>( &'life0 self, pid: &'life1 str, wake: Option<WakeSet>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Sets or clears the wake set of pid.

§Errors

Returns KernelError::NotFound when no row has pid, or KernelError::Store when the backend fails.

Source

fn set_queue<'life0, 'life1, 'async_trait>( &'life0 self, pid: &'life1 str, queue: QueueClass, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Sets the queue class of pid.

§Errors

Returns KernelError::NotFound when no row has pid, or KernelError::Store when the backend fails.

Source

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

Deletes the row of pid; false when there was none.

§Errors

Returns KernelError::Store when the backend fails.

Source

fn set_suspend_requested<'life0, 'life1, 'async_trait>( &'life0 self, pid: &'life1 str, requested: bool, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Sets or clears the pending suspension request of pid (ProcessMeta::suspend_requested).

§Errors

Returns KernelError::NotFound when no row has pid, or KernelError::Store when the backend fails.

Source

fn add_spend<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, pid: &'life1 str, partition: &'life2 PartitionId, day: NaiveDate, delta: SpendDelta, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Adds delta — its cost, model calls, total tokens and units — to the totals of pid in partition on the UTC day day. Additions from concurrent writers all count.

§Errors

Returns KernelError::Store when the backend fails.

Source

fn spend<'life0, 'life1, 'async_trait>( &'life0 self, scope: &'life1 SpendScope, from: NaiveDate, to_inclusive: NaiveDate, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The spend scope recorded from from through to_inclusive, in micro-USD; 0 when none was.

§Errors

Returns KernelError::Store when the backend fails.

Source

fn usage<'life0, 'life1, 'async_trait>( &'life0 self, scope: &'life1 SpendScope, from: NaiveDate, to_inclusive: NaiveDate, ) -> Pin<Box<dyn Future<Output = Result<UsageTotals>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

What scope used from from through to_inclusive: the cost, model calls, total tokens and units add_spend recorded; zero when none was.

§Errors

Returns KernelError::Store when the backend fails.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§