risingwave_object_store/object/opendal_engine/
obs.rsuse std::sync::Arc;
use opendal::layers::LoggingLayer;
use opendal::services::Obs;
use opendal::Operator;
use risingwave_common::config::ObjectStoreConfig;
use super::{MediaType, OpendalObjectStore};
use crate::object::object_metrics::ObjectStoreMetrics;
use crate::object::ObjectResult;
impl OpendalObjectStore {
pub fn new_obs_engine(
bucket: String,
root: String,
config: Arc<ObjectStoreConfig>,
metrics: Arc<ObjectStoreMetrics>,
) -> ObjectResult<Self> {
let mut builder = Obs::default().bucket(&bucket).root(&root);
let endpoint = std::env::var("OBS_ENDPOINT")
.unwrap_or_else(|_| panic!("OBS_ENDPOINT not found from environment variables"));
let access_key_id = std::env::var("OBS_ACCESS_KEY_ID")
.unwrap_or_else(|_| panic!("OBS_ACCESS_KEY_ID not found from environment variables"));
let secret_access_key = std::env::var("OBS_SECRET_ACCESS_KEY").unwrap_or_else(|_| {
panic!("OBS_SECRET_ACCESS_KEY not found from environment variables")
});
builder = builder
.endpoint(&endpoint)
.access_key_id(&access_key_id)
.secret_access_key(&secret_access_key);
let op: Operator = Operator::new(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(Self {
op,
media_type: MediaType::Obs,
config,
metrics,
})
}
}