risingwave_object_store/object/opendal_engine/
azblob.rs1use std::sync::Arc;
16
17use opendal::Operator;
18use opendal::layers::LoggingLayer;
19use opendal::services::Azblob;
20use risingwave_common::config::ObjectStoreConfig;
21
22use super::{MediaType, OpendalObjectStore};
23use crate::object::ObjectResult;
24use crate::object::object_metrics::ObjectStoreMetrics;
25
26const AZBLOB_ENDPOINT: &str = "AZBLOB_ENDPOINT";
27impl OpendalObjectStore {
28 pub fn new_azblob_engine(
30 container_name: String,
31 root: String,
32 config: Arc<ObjectStoreConfig>,
33 metrics: Arc<ObjectStoreMetrics>,
34 ) -> ObjectResult<Self> {
35 let mut builder = Azblob::default().root(&root).container(&container_name);
37
38 let endpoint = std::env::var(AZBLOB_ENDPOINT)
39 .unwrap_or_else(|_| panic!("AZBLOB_ENDPOINT not found from environment variables"));
40
41 builder = builder.endpoint(&endpoint);
42
43 let op: Operator = Operator::new(builder)?
44 .layer(LoggingLayer::default())
45 .finish();
46 Ok(Self {
47 op,
48 media_type: MediaType::Azblob,
49 config,
50 metrics,
51 })
52 }
53}