Skip to content

Commit

Permalink
chore(core/layers): align info method of trait Access and trait Layer…
Browse files Browse the repository at this point in the history
…edAccess
  • Loading branch information
koushiro committed Oct 31, 2024
1 parent e5076ac commit 57d8ec7
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion core/src/layers/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl<A: Access> LayeredAccess for BlockingAccessor<A> {
&self.inner
}

fn metadata(&self) -> Arc<AccessorInfo> {
fn info(&self) -> Arc<AccessorInfo> {
let mut meta = self.inner.info().as_ref().clone();
meta.full_capability_mut().blocking = true;
meta.into()
Expand Down
2 changes: 1 addition & 1 deletion core/src/layers/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ impl<A: Access> LayeredAccess for CompleteAccessor<A> {
}

// Todo: May move the logic to the implement of Layer::layer of CompleteAccessor<A>
fn metadata(&self) -> Arc<AccessorInfo> {
fn info(&self) -> Arc<AccessorInfo> {
let mut meta = (*self.meta).clone();
let cap = meta.full_capability_mut();
if cap.list && cap.write_can_empty {
Expand Down
2 changes: 1 addition & 1 deletion core/src/layers/error_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<A: Access> LayeredAccess for ErrorContextAccessor<A> {
&self.inner
}

fn metadata(&self) -> Arc<AccessorInfo> {
fn info(&self) -> Arc<AccessorInfo> {
self.meta.clone()
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/layers/fastrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<A: Access> LayeredAccess for FastraceAccessor<A> {
}

#[trace]
fn metadata(&self) -> Arc<AccessorInfo> {
fn info(&self) -> Arc<AccessorInfo> {
self.inner.info()
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/layers/immutable_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl<A: Access> LayeredAccess for ImmutableIndexAccessor<A> {
}

/// Add list capabilities for underlying storage services.
fn metadata(&self) -> Arc<AccessorInfo> {
fn info(&self) -> Arc<AccessorInfo> {
let mut meta = (*self.inner.info()).clone();

let cap = meta.full_capability_mut();
Expand Down
2 changes: 1 addition & 1 deletion core/src/layers/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl<A: Access, I: LoggingInterceptor> LayeredAccess for LoggingAccessor<A, I> {
&self.inner
}

fn metadata(&self) -> Arc<AccessorInfo> {
fn info(&self) -> Arc<AccessorInfo> {
self.logger
.log(&self.info, Operation::Info, &[], "started", None);

Expand Down
2 changes: 1 addition & 1 deletion core/src/layers/oteltrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<A: Access> LayeredAccess for OtelTraceAccessor<A> {
&self.inner
}

fn metadata(&self) -> Arc<AccessorInfo> {
fn info(&self) -> Arc<AccessorInfo> {
let tracer = global::tracer("opendal");
tracer.in_span("metadata", |_cx| self.inner.info())
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/layers/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<A: Access> LayeredAccess for TracingAccessor<A> {
}

#[tracing::instrument(level = "debug")]
fn metadata(&self) -> Arc<AccessorInfo> {
fn info(&self) -> Arc<AccessorInfo> {
self.inner.info()
}

Expand Down
45 changes: 22 additions & 23 deletions core/src/raw/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ pub trait Layer<A: Access> {
/// LayeredAccess is layered accessor that forward all not implemented
/// method to inner.
#[allow(missing_docs)]

pub trait LayeredAccess: Send + Sync + Debug + Unpin + 'static {
type Inner: Access;
type Reader: oio::Read;
Expand All @@ -140,7 +139,7 @@ pub trait LayeredAccess: Send + Sync + Debug + Unpin + 'static {

fn inner(&self) -> &Self::Inner;

fn metadata(&self) -> Arc<AccessorInfo> {
fn info(&self) -> Arc<AccessorInfo> {
self.inner().info()
}

Expand Down Expand Up @@ -241,86 +240,86 @@ pub trait LayeredAccess: Send + Sync + Debug + Unpin + 'static {

impl<L: LayeredAccess> Access for L {
type Reader = L::Reader;
type BlockingReader = L::BlockingReader;
type Writer = L::Writer;
type BlockingWriter = L::BlockingWriter;
type Lister = L::Lister;
type BlockingReader = L::BlockingReader;
type BlockingWriter = L::BlockingWriter;
type BlockingLister = L::BlockingLister;

fn info(&self) -> Arc<AccessorInfo> {
(self as &L).metadata()
LayeredAccess::info(self)
}

async fn create_dir(&self, path: &str, args: OpCreateDir) -> Result<RpCreateDir> {
(self as &L).create_dir(path, args).await
LayeredAccess::create_dir(self, path, args).await
}

async fn read(&self, path: &str, args: OpRead) -> Result<(RpRead, Self::Reader)> {
(self as &L).read(path, args).await
LayeredAccess::read(self, path, args).await
}

async fn write(&self, path: &str, args: OpWrite) -> Result<(RpWrite, Self::Writer)> {
(self as &L).write(path, args).await
LayeredAccess::write(self, path, args).await
}

async fn copy(&self, from: &str, to: &str, args: OpCopy) -> Result<RpCopy> {
(self as &L).copy(from, to, args).await
LayeredAccess::copy(self, from, to, args).await
}

async fn rename(&self, from: &str, to: &str, args: OpRename) -> Result<RpRename> {
(self as &L).rename(from, to, args).await
LayeredAccess::rename(self, from, to, args).await
}

async fn stat(&self, path: &str, args: OpStat) -> Result<RpStat> {
(self as &L).stat(path, args).await
LayeredAccess::stat(self, path, args).await
}

async fn delete(&self, path: &str, args: OpDelete) -> Result<RpDelete> {
(self as &L).delete(path, args).await
LayeredAccess::delete(self, path, args).await
}

async fn list(&self, path: &str, args: OpList) -> Result<(RpList, Self::Lister)> {
(self as &L).list(path, args).await
LayeredAccess::list(self, path, args).await
}

async fn batch(&self, args: OpBatch) -> Result<RpBatch> {
(self as &L).batch(args).await
LayeredAccess::batch(self, args).await
}

async fn presign(&self, path: &str, args: OpPresign) -> Result<RpPresign> {
(self as &L).presign(path, args).await
LayeredAccess::presign(self, path, args).await
}

fn blocking_create_dir(&self, path: &str, args: OpCreateDir) -> Result<RpCreateDir> {
(self as &L).blocking_create_dir(path, args)
LayeredAccess::blocking_create_dir(self, path, args)
}

fn blocking_read(&self, path: &str, args: OpRead) -> Result<(RpRead, Self::BlockingReader)> {
(self as &L).blocking_read(path, args)
LayeredAccess::blocking_read(self, path, args)
}

fn blocking_write(&self, path: &str, args: OpWrite) -> Result<(RpWrite, Self::BlockingWriter)> {
(self as &L).blocking_write(path, args)
LayeredAccess::blocking_write(self, path, args)
}

fn blocking_copy(&self, from: &str, to: &str, args: OpCopy) -> Result<RpCopy> {
(self as &L).blocking_copy(from, to, args)
LayeredAccess::blocking_copy(self, from, to, args)
}

fn blocking_rename(&self, from: &str, to: &str, args: OpRename) -> Result<RpRename> {
(self as &L).blocking_rename(from, to, args)
LayeredAccess::blocking_rename(self, from, to, args)
}

fn blocking_stat(&self, path: &str, args: OpStat) -> Result<RpStat> {
(self as &L).blocking_stat(path, args)
LayeredAccess::blocking_stat(self, path, args)
}

fn blocking_delete(&self, path: &str, args: OpDelete) -> Result<RpDelete> {
(self as &L).blocking_delete(path, args)
LayeredAccess::blocking_delete(self, path, args)
}

fn blocking_list(&self, path: &str, args: OpList) -> Result<(RpList, Self::BlockingLister)> {
(self as &L).blocking_list(path, args)
LayeredAccess::blocking_list(self, path, args)
}
}

Expand Down

0 comments on commit 57d8ec7

Please sign in to comment.