risingwave_object_store/object/opendal_engine/
oss.rsuse std::sync::Arc;
use opendal::layers::LoggingLayer;
use opendal::services::Oss;
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_oss_engine(
bucket: String,
root: String,
config: Arc<ObjectStoreConfig>,
metrics: Arc<ObjectStoreMetrics>,
) -> ObjectResult<Self> {
let mut builder = Oss::default().bucket(&bucket).root(&root);
let endpoint = std::env::var("OSS_ENDPOINT")
.unwrap_or_else(|_| panic!("OSS_ENDPOINT not found from environment variables"));
let access_key_id = std::env::var("OSS_ACCESS_KEY_ID")
.unwrap_or_else(|_| panic!("OSS_ACCESS_KEY_ID not found from environment variables"));
let access_key_secret = std::env::var("OSS_ACCESS_KEY_SECRET").unwrap_or_else(|_| {
panic!("OSS_ACCESS_KEY_SECRET not found from environment variables")
});
builder = builder
.endpoint(&endpoint)
.access_key_id(&access_key_id)
.access_key_secret(&access_key_secret);
let op: Operator = Operator::new(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(Self {
op,
media_type: MediaType::Oss,
config,
metrics,
})
}
}