use async_trait::async_trait;
use serde_json::Value;
use std::time::Duration;
use super::errors::Result;
use super::watch::WatchStream;
#[derive(Debug)]
pub struct KeyValueVersion {
pub key: String,
pub value: Vec<u8>,
pub version: i64,
}
#[derive(Debug)]
pub enum MetaOptions {
None,
WithPrefix,
WithPrevKey,
}
#[async_trait]
pub trait MetadataStore: Send + Sync + 'static {
async fn get(&self, key: &str, get_options: MetaOptions) -> Result<Option<Value>>;
async fn get_childrens(&self, path: &str) -> Result<Vec<String>>;
async fn put(&self, key: &str, value: Value, put_options: MetaOptions) -> Result<()>;
async fn delete(&self, key: &str) -> Result<()>;
async fn watch(&self, prefix: &str) -> Result<WatchStream>;
async fn put_with_ttl(&self, key: &str, value: Value, ttl: Duration) -> Result<()>;
async fn get_bulk(&self, prefix: &str) -> Result<Vec<KeyValueVersion>>;
async fn allocate_monotonic_id(&self, counter_key: &str) -> Result<u64>;
}