-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: congyi wang <58715567+wcy-fdu@users.noreply.github.com>
- Loading branch information
1 parent
bdb7aab
commit 43b731d
Showing
6 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ pub mod webhdfs; | |
|
||
pub mod gcs; | ||
|
||
pub mod obs; | ||
|
||
pub mod oss; | ||
|
||
pub mod azblob; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2023 RisingWave Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use opendal::layers::{LoggingLayer, RetryLayer}; | ||
use opendal::services::Obs; | ||
use opendal::Operator; | ||
|
||
use super::{EngineType, OpendalObjectStore}; | ||
use crate::object::ObjectResult; | ||
|
||
impl OpendalObjectStore { | ||
/// create opendal obs engine. | ||
pub fn new_obs_engine(bucket: String, root: String) -> ObjectResult<Self> { | ||
// Create obs backend builder. | ||
let mut builder = Obs::default(); | ||
|
||
builder.bucket(&bucket); | ||
|
||
builder.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.endpoint(&endpoint); | ||
builder.access_key_id(&access_key_id); | ||
builder.secret_access_key(&secret_access_key); | ||
let op: Operator = Operator::new(builder)? | ||
.layer(LoggingLayer::default()) | ||
.layer(RetryLayer::default()) | ||
.finish(); | ||
Ok(Self { | ||
op, | ||
engine_type: EngineType::Obs, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters