danube_core/metadata/
store.rs1use async_trait::async_trait;
2use serde_json::Value;
3use std::time::Duration;
4
5use super::errors::Result;
6use super::watch::WatchStream;
7
8#[derive(Debug)]
10pub struct KeyValueVersion {
11 pub key: String,
12 pub value: Vec<u8>,
13 pub version: i64,
14}
15
16#[derive(Debug)]
18pub enum MetaOptions {
19 None,
20 WithPrefix,
22 WithPrevKey,
24}
25
26#[async_trait]
27pub trait MetadataStore: Send + Sync + 'static {
28 async fn get(&self, key: &str, get_options: MetaOptions) -> Result<Option<Value>>;
29 async fn get_childrens(&self, path: &str) -> Result<Vec<String>>;
30 async fn put(&self, key: &str, value: Value, put_options: MetaOptions) -> Result<()>;
31 async fn delete(&self, key: &str) -> Result<()>;
32 async fn watch(&self, prefix: &str) -> Result<WatchStream>;
33
34 async fn put_with_ttl(&self, key: &str, value: Value, ttl: Duration) -> Result<()>;
36
37 async fn get_bulk(&self, prefix: &str) -> Result<Vec<KeyValueVersion>>;
39
40 async fn allocate_monotonic_id(&self, counter_key: &str) -> Result<u64>;
45}