Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ services-gcs = ["dep:opendal-service-gcs"]
services-gdrive = ["dep:opendal-service-gdrive"]
services-ghac = ["dep:opendal-service-ghac"]
services-github = ["dep:opendal-service-github"]
services-gridfs = ["opendal-core/services-gridfs"]
services-gridfs = ["dep:opendal-service-gridfs"]
services-hdfs = ["dep:opendal-service-hdfs"]
services-hdfs-native = ["dep:opendal-service-hdfs-native"]
services-http = ["dep:opendal-service-http"]
Expand Down Expand Up @@ -171,7 +171,7 @@ services-surrealdb = ["dep:opendal-service-surrealdb"]
services-swift = ["dep:opendal-service-swift"]
services-tikv = ["dep:opendal-service-tikv"]
services-upyun = ["dep:opendal-service-upyun"]
services-vercel-artifacts = ["opendal-core/services-vercel-artifacts"]
services-vercel-artifacts = ["dep:opendal-service-vercel-artifacts"]
services-vercel-blob = ["dep:opendal-service-vercel-blob"]
services-webdav = ["dep:opendal-service-webdav"]
services-webhdfs = ["dep:opendal-service-webhdfs"]
Expand Down Expand Up @@ -241,6 +241,7 @@ opendal-service-gcs = { path = "services/gcs", version = "0.55.0", optional = tr
opendal-service-gdrive = { path = "services/gdrive", version = "0.55.0", optional = true, default-features = false }
opendal-service-ghac = { path = "services/ghac", version = "0.55.0", optional = true, default-features = false }
opendal-service-github = { path = "services/github", version = "0.55.0", optional = true, default-features = false }
opendal-service-gridfs = { path = "services/gridfs", version = "0.55.0", optional = true, default-features = false }
opendal-service-hdfs = { path = "services/hdfs", version = "0.55.0", optional = true, default-features = false }
opendal-service-hdfs-native = { path = "services/hdfs-native", version = "0.55.0", optional = true, default-features = false }
opendal-service-http = { path = "services/http", version = "0.55.0", optional = true, default-features = false }
Expand Down Expand Up @@ -270,6 +271,7 @@ opendal-service-surrealdb = { path = "services/surrealdb", version = "0.55.0", o
opendal-service-swift = { path = "services/swift", version = "0.55.0", optional = true, default-features = false }
opendal-service-tikv = { path = "services/tikv", version = "0.55.0", optional = true, default-features = false }
opendal-service-upyun = { path = "services/upyun", version = "0.55.0", optional = true, default-features = false }
opendal-service-vercel-artifacts = { path = "services/vercel-artifacts", version = "0.55.0", optional = true, default-features = false }
opendal-service-vercel-blob = { path = "services/vercel-blob", version = "0.55.0", optional = true, default-features = false }
opendal-service-webdav = { path = "services/webdav", version = "0.55.0", optional = true, default-features = false }
opendal-service-webhdfs = { path = "services/webhdfs", version = "0.55.0", optional = true, default-features = false }
Expand Down
5 changes: 0 additions & 5 deletions core/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,11 @@ executors-tokio = ["tokio/rt"]
# Enable dtrace support.
layers-dtrace = ["dep:probe"]

services-gridfs = ["dep:mongodb", "dep:mongodb-internal-macros"]
services-ipmfs = []
services-lakefs = []
services-memory = []
services-mongodb = ["dep:mongodb", "dep:mongodb-internal-macros"]
services-redis = ["dep:redis", "dep:fastpool", "redis?/tokio-rustls-comp"]
services-redis-native-tls = ["services-redis", "redis?/tokio-native-tls-comp"]
services-rocksdb = ["dep:rocksdb", "internal-tokio-rt"]
services-vercel-artifacts = []
services-webhdfs = []

[lib]
bench = false
Expand Down
5 changes: 0 additions & 5 deletions core/core/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
//!
//! More ongoing services support is tracked at [opendal#5](https://github.com/apache/opendal/issues/5). Please feel free to submit issues if there are services not covered.

#[cfg(feature = "services-gridfs")]
mod gridfs;
#[cfg(feature = "services-gridfs")]
pub use gridfs::*;

#[cfg(feature = "services-memory")]
mod memory;
#[cfg(feature = "services-memory")]
Expand Down
42 changes: 42 additions & 0 deletions core/services/gridfs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

[package]
description = "Apache OpenDAL GridFS service implementation"
name = "opendal-service-gridfs"

authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }
version = { workspace = true }

[package.metadata.docs.rs]
all-features = true

[dependencies]
ctor = { workspace = true }
futures = { workspace = true }
mea = "0.5.1"
mongodb = "3.3.0"
opendal-core = { path = "../../core", version = "0.55.0", default-features = false }
serde = { workspace = true, features = ["derive"] }

[dev-dependencies]
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
use std::sync::Arc;

use mea::once::OnceCell;
use opendal_core::raw::*;
use opendal_core::*;

use super::GRIDFS_SCHEME;
use super::config::GridfsConfig;
use super::core::*;
use super::deleter::GridfsDeleter;
use super::writer::GridfsWriter;
use crate::raw::*;
use crate::*;

#[doc = include_str!("docs.md")]
#[derive(Debug, Default)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use std::fmt::Debug;

use opendal_core::*;
use serde::Deserialize;
use serde::Serialize;

Expand Down Expand Up @@ -50,10 +51,10 @@ impl Debug for GridfsConfig {
}
}

impl crate::Configurator for GridfsConfig {
impl Configurator for GridfsConfig {
type Builder = GridfsBuilder;

fn from_uri(uri: &crate::types::OperatorUri) -> crate::Result<Self> {
fn from_uri(uri: &OperatorUri) -> Result<Self> {
let mut map = uri.options().clone();

if let Some(authority) = uri.authority() {
Expand Down Expand Up @@ -95,24 +96,22 @@ impl crate::Configurator for GridfsConfig {
#[cfg(test)]
mod tests {
use super::*;
use crate::Configurator;
use crate::types::OperatorUri;

#[test]
fn from_uri_sets_connection_database_bucket_and_root() {
fn from_uri_sets_connection_database_bucket_and_root() -> Result<()> {
let uri = OperatorUri::new(
"gridfs://mongo.example.com:27017/app_files/assets/images",
Vec::<(String, String)>::new(),
)
.unwrap();
)?;

let cfg = GridfsConfig::from_uri(&uri).unwrap();
let cfg = GridfsConfig::from_uri(&uri)?;
assert_eq!(
cfg.connection_string.as_deref(),
Some("mongodb://mongo.example.com:27017")
);
assert_eq!(cfg.database.as_deref(), Some("app_files"));
assert_eq!(cfg.bucket.as_deref(), Some("assets"));
assert_eq!(cfg.root.as_deref(), Some("images"));
Ok(())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ use mongodb::bson::doc;
use mongodb::gridfs::GridFsBucket;
use mongodb::options::ClientOptions;
use mongodb::options::GridFsBucketOptions;

use crate::raw::*;
use crate::*;
use opendal_core::raw::*;
use opendal_core::*;

#[derive(Clone)]
pub struct GridfsCore {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

use std::sync::Arc;

use opendal_core::raw::*;
use opendal_core::*;

use super::core::*;
use crate::raw::oio;
use crate::raw::*;
use crate::*;

pub struct GridfsDeleter {
core: Arc<GridfsCore>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ This service can be used to:
### Via Builder

```rust,no_run
use anyhow::Result;
use opendal_core::services::Gridfs;
use opendal_core::Operator;
use opendal_core::Result;
use opendal_service_gridfs::Gridfs;

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
// specific language governing permissions and limitations
// under the License.

/// Default scheme for gridfs service.
pub const GRIDFS_SCHEME: &str = "gridfs";
//! GridFS service implementation for Apache OpenDAL.

use crate::types::DEFAULT_OPERATOR_REGISTRY;
#![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(missing_docs)]

mod backend;
mod config;
Expand All @@ -29,7 +29,10 @@ mod writer;
pub use backend::GridfsBuilder as Gridfs;
pub use config::GridfsConfig;

/// Default scheme for gridfs service.
pub const GRIDFS_SCHEME: &str = "gridfs";

#[ctor::ctor]
fn register_gridfs_service() {
DEFAULT_OPERATOR_REGISTRY.register::<Gridfs>(GRIDFS_SCHEME);
opendal_core::DEFAULT_OPERATOR_REGISTRY.register::<Gridfs>(GRIDFS_SCHEME);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

use std::sync::Arc;

use opendal_core::raw::*;
use opendal_core::*;

use super::core::*;
use crate::raw::oio;
use crate::*;

pub struct GridfsWriter {
core: Arc<GridfsCore>,
Expand Down
2 changes: 2 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ pub mod services {
pub use opendal_service_ghac::*;
#[cfg(feature = "services-github")]
pub use opendal_service_github::*;
#[cfg(feature = "services-gridfs")]
pub use opendal_service_gridfs::*;
#[cfg(feature = "services-hdfs")]
pub use opendal_service_hdfs::*;
#[cfg(feature = "services-hdfs-native")]
Expand Down
Loading