You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "Xuanwo (via GitHub)" <gi...@apache.org> on 2024/07/24 10:56:01 UTC

[PR] feat(!): Allow users to build operator from config [opendal]

Xuanwo opened a new pull request, #4919:
URL: https://github.com/apache/opendal/pull/4919

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Part of https://github.com/apache/opendal/issues/3240.
   
   # Rationale for this change
   
   This adds `Operator::from_config` support so users can build operator from config directly:
   
   ```rust
   use std::collections::HashMap;
   
   use opendal::services::MemoryConfig;
   use opendal::Operator;
   async fn test() -> Result<()> {
       let mut cfg = MemoryConfig::default();
       cfg. root = Some("/".to_string());
   
       // Build an `Operator` to start operating the storage.
       let op: Operator = Operator::from_config(cfg)?.finish();
   
       Ok(())
   }
   ```
   
   We have to introduce a new trait `Configurator` since we can't infer `B` while given `B::Config`.
   
   # What changes are included in this PR?
   
   New API `Operator::from_config`. This API also changed `Builder`:
   
   ```diff
   - fn build(&mut self) -> Result<Self::Accessor>;
   + fn build(self) -> Result<impl Access>;
   ```
   
   This change fixed long existed issues about `reusing builder` and lifetime.
   
   # Are there any user-facing changes?
   
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking-changes` label.
   -->
   
   This is breaking change PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(!): Allow users to build operator from config [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #4919:
URL: https://github.com/apache/opendal/pull/4919


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org