key_value
ModuleA key-value store on a JetStream stream (KV_<bucket>).
Contents
use utopia_nats::key_value::KeyValue;Rust
pub struct KeyValueA key-value bucket.
Rust
use utopia_nats::key_value::KeyValueConfig;
let js = connection.jetstream(None, None);
let kv = js.create_key_value(&mut connection, &KeyValueConfig { history: 5, ..KeyValueConfig::new("doc_config") }).await?;
let revision = kv.put(&mut connection, "app.name", "My Service").await?;
let entry = kv.get(&mut connection, "app.name").await?;
assert_eq!((entry.value.as_ref(), entry.revision), (&b"My Service"[..], revision));
js.delete_key_value(&mut connection, "doc_config").await?;use utopia_nats::key_value::KeyValueConfig;Rust
pub struct KeyValueConfigA bucket's configuration.
use utopia_nats::key_value::KeyValueEntry;Rust
pub struct KeyValueEntryOne revision of a key.
use utopia_nats::key_value::KeyValueStatus;Rust
pub struct KeyValueStatusA bucket's size and settings.
use utopia_nats::key_value::KeyValueWatchOptions;Rust
pub struct KeyValueWatchOptionsWhat a watch delivers.
use utopia_nats::key_value::KeyValueOperation;Rust
pub enum KeyValueOperationWhat an entry records.
Rust
pub type EntryCallback = Box<dyn FnMut(KeyValueEntry) -> Result<(), CallbackError> + Send>A callback receiving watched entries.
Rust
pub type InitCallback = Box<dyn FnMut() -> Result<(), CallbackError> + Send>Called once the initial set of a watch was delivered.