You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "miroim (via GitHub)" <gi...@apache.org> on 2025/04/03 02:30:58 UTC

[PR] refactor: Introduce IpfsCore for improved service structure [opendal]

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

   # Which issue does this PR close?
   Part of https://github.com/apache/opendal/issues/5702
   
   <!--
   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.
   -->
   
   
   # Rationale for this change
   
   <!--
   Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
   Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
   -->
   
   # What changes are included in this PR?
   This pull request refactors the `IpfsBackend` by introducing a new `IpfsCore` struct to encapsulate the core functionality and state. The changes aim to improve code organization and maintainability. 
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # 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 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] refactor: Introduce IpfsCore for improved service structure [opendal]

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


-- 
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] refactor: Introduce IpfsCore for improved service structure [opendal]

Posted by "erickguan (via GitHub)" <gi...@apache.org>.
erickguan commented on PR #5950:
URL: https://github.com/apache/opendal/pull/5950#issuecomment-2779880404

   Good plan. Thanks for sharing some love for IPFS!


-- 
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] refactor: Introduce IpfsCore for improved service structure [opendal]

Posted by "miroim (via GitHub)" <gi...@apache.org>.
miroim commented on PR #5950:
URL: https://github.com/apache/opendal/pull/5950#issuecomment-2774218652

   <details>
   <summary>Behavior tests</summary>
   
   ```
   cargo test behavior --features tests,services-ipfs -- --show-output
       Finished `test` profile [unoptimized + debuginfo] target(s) in 3.08s
        Running unittests src\lib.rs (target\debug\deps\opendal-90b9ea2d0dddfb7c.exe)
   
   running 0 tests
   
   successes:
   
   successes:
   
   test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 134 filtered out; finished in 0.00s
   
        Running tests\behavior\main.rs (target\debug\deps\behavior-c0c901956f19c793.exe)
   
   running 23 tests
   test behavior::test_read_only_read_with_range              ... ok
   test behavior::test_read_only_read_full_with_special_chars ... ok
   test behavior::test_read_only_read_with_dir_path           ... ok
   test behavior::test_read_only_read_with_if_match           ... ok
   test behavior::test_read_only_read_with_if_none_match      ... ok
   test behavior::test_reader_only_read_with_if_match         ... ok
   test behavior::test_reader_only_read_with_if_none_match    ... ok
   test behavior::test_read_only_read_full                    ... ok
   test behavior::test_read_only_read_not_exist               ... ok
   test behavior::test_read_only_stat_not_cleaned_path        ... ok
   test behavior::test_read_only_stat_file_and_dir            ... ok
   test behavior::test_read_only_stat_with_if_match           ... ok
   test behavior::test_read_only_stat_with_if_none_match      ... ok
   test behavior::test_read_only_stat_root                    ... ok
   test behavior::test_read_only_stat_not_exist               ... ok
   test behavior::test_read_only_stat_special_chars           ... ok
   test behavior::test_blocking_read_only_stat_file_and_dir   ... ok
   test behavior::test_blocking_read_only_stat_not_exist      ... ok
   test behavior::test_blocking_read_only_stat_special_chars  ... ok
   test behavior::test_blocking_read_only_read_with_range     ... ok
   test behavior::test_blocking_read_only_read_not_exist      ... ok
   test behavior::test_blocking_read_only_read_full           ... ok
   test behavior::test_list_only                              ... ok
   
   test result: ok. 23 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.47s
   ```
   
   </details>


-- 
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] refactor: Introduce IpfsCore for improved service structure [opendal]

Posted by "miroim (via GitHub)" <gi...@apache.org>.
miroim commented on code in PR #5950:
URL: https://github.com/apache/opendal/pull/5950#discussion_r2028841081


##########
core/src/services/ipfs/backend.rs:
##########
@@ -435,7 +379,7 @@ impl DirStream {
 
 impl oio::PageList for DirStream {
     async fn next_page(&self, ctx: &mut oio::PageContext) -> Result<()> {
-        let resp = self.backend.ipfs_list(&self.path).await?;
+        let resp = self.backend.core.ipfs_list(&self.path).await?;

Review Comment:
   Thanks for your review!
   
   `DirStream` needs some `backend` functionality
   https://github.com/apache/opendal/blob/36240c1aa186c287a6456adf7083311ef237b042/core/src/services/ipfs/backend.rs#L400-L404
   or we can  have:
   ```Rust
   pub struct DirStream {
       backend: Arc<IpfsBackend>,
       core: Arc<IpfsCore>,
       path: String,
   }
   ```



-- 
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] refactor: Introduce IpfsCore for improved service structure [opendal]

Posted by "erickguan (via GitHub)" <gi...@apache.org>.
erickguan commented on code in PR #5950:
URL: https://github.com/apache/opendal/pull/5950#discussion_r2029422349


##########
core/src/services/ipfs/backend.rs:
##########
@@ -435,7 +379,7 @@ impl DirStream {
 
 impl oio::PageList for DirStream {
     async fn next_page(&self, ctx: &mut oio::PageContext) -> Result<()> {
-        let resp = self.backend.ipfs_list(&self.path).await?;
+        let resp = self.backend.core.ipfs_list(&self.path).await?;

Review Comment:
   Yes, you're right - we are depending on `IpfsBackend::stat`. Could we take it a step further and build a function like `pub async fn IpfsCore::ipfs_stat(name: &str) -> Result<Metadata>`? This would allow you to retrieve metadata for each name directly via the core for `DirStream`.
   
   As aside, while this change improves the structure, it doesn't resolve the N+1 issue... That is not related to the issue. So we can ignore it for now.



-- 
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] refactor: Introduce IpfsCore for improved service structure [opendal]

Posted by "miroim (via GitHub)" <gi...@apache.org>.
miroim commented on code in PR #5950:
URL: https://github.com/apache/opendal/pull/5950#discussion_r2029499502


##########
core/src/services/ipfs/backend.rs:
##########
@@ -435,7 +379,7 @@ impl DirStream {
 
 impl oio::PageList for DirStream {
     async fn next_page(&self, ctx: &mut oio::PageContext) -> Result<()> {
-        let resp = self.backend.ipfs_list(&self.path).await?;
+        let resp = self.backend.core.ipfs_list(&self.path).await?;

Review Comment:
   > Could we take it a step further and build a function like pub async fn IpfsCore::ipfs_stat(name: &str) -> Result<Metadata>?
   
   Yes, I'll raise another 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] refactor: Introduce IpfsCore for improved service structure [opendal]

Posted by "erickguan (via GitHub)" <gi...@apache.org>.
erickguan commented on code in PR #5950:
URL: https://github.com/apache/opendal/pull/5950#discussion_r2027647453


##########
core/src/services/ipfs/backend.rs:
##########
@@ -435,7 +379,7 @@ impl DirStream {
 
 impl oio::PageList for DirStream {
     async fn next_page(&self, ctx: &mut oio::PageContext) -> Result<()> {
-        let resp = self.backend.ipfs_list(&self.path).await?;
+        let resp = self.backend.core.ipfs_list(&self.path).await?;

Review Comment:
   Can we reference `self.core` directly without going from `backend`?
   
   Because you have `IpfsCore`, we can have:
   
   ```rust
   pub struct DirStream {
       core: Arc<IpfsCore>,
       path: String,
   }
   ```



##########
core/src/services/ipfs/backend.rs:
##########
@@ -93,6 +97,8 @@ impl IpfsBuilder {
     ///
     /// This API is part of OpenDAL's Raw API. `HttpClient` could be changed
     /// during minor updates.
+    #[deprecated(since = "0.53.0", note = "Use `Operator::update_http_client` instead")]

Review Comment:
   💯 



-- 
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