Closed cprice404 closed 2 months ago
Using all 3 clients, you'd need to specify the path to each config
use std::time::Duration;
use momento::{
cache, storage, topics, CacheClient, CredentialProvider, MomentoResult, PreviewStorageClient,
TopicClient,
};
#[tokio::main(flavor = "current_thread")]
async fn main() -> MomentoResult<()> {
let storage_client = PreviewStorageClient::builder()
.configuration(storage::configurations::Laptop::latest())
.credential_provider(
CredentialProvider::from_env_var("MOMENTO_API_KEY".to_string())
.expect("API key should be valid"),
)
.build()?;
let topic_client = TopicClient::builder()
.configuration(topics::configurations::Laptop::latest())
.credential_provider(
CredentialProvider::from_env_var("MOMENTO_API_KEY".to_string())
.expect("API key should be valid"),
)
.build()?;
let cache_client = CacheClient::builder()
.default_ttl(Duration::from_secs(60))
.configuration(cache::configurations::Laptop::latest())
.credential_provider(
CredentialProvider::from_env_var("MOMENTO_API_KEY".to_string())
.expect("API key should be valid"),
)
.build()?;
Ok(())
}
Thanks for the example @anitarua ! I honestly think I'm okay with that and can't immediately think of a much better way to do it. @malandis any thoughts?
e.g., what does it look like if you try to use the
Laptop
config for both topics and cache in the same program?