wasmcloud_provider_blobstore_nats/lib.rs
1use crate::config::{NatsConnectionConfig, StorageConfig};
2/// [`wasmcloud_provider_blobstore_nats`] crate is a NATS JetStream implementation of the wasmCloud's "wrpc:blobstore/blobstore@0.2.0" interface.
3use std::collections::HashMap;
4use std::sync::Arc;
5use tokio::sync::RwLock;
6
7/// [`NatsBlobstore`] holds the handle to opened NATS Object Stores, and their container (bucket) storage configuration.
8#[derive(Clone)]
9pub(crate) struct NatsBlobstore {
10 pub(crate) jetstream: async_nats::jetstream::context::Context,
11 pub(crate) storage_config: StorageConfig,
12}
13
14/// [`NatsBlobstoreProvider`] holds the default NATS connection configuration and individual consumer
15/// components' established NATS JetStream connections.
16#[derive(Default, Clone)]
17pub struct NatsBlobstoreProvider {
18 /// Map of component_id -> link_name -> NATS Object Store JetStream Context (supports multiple links per component)
19 consumer_components: Arc<RwLock<HashMap<String, HashMap<String, NatsBlobstore>>>>,
20 default_config: NatsConnectionConfig,
21}
22
23mod blobstore;
24/// Provider modules
25mod config;
26mod provider;