Skip to content

feat(binding/go): Add Copier#7732

Open
FrankYang0529 wants to merge 1 commit into
apache:mainfrom
FrankYang0529:opendal-7731
Open

feat(binding/go): Add Copier#7732
FrankYang0529 wants to merge 1 commit into
apache:mainfrom
FrankYang0529:opendal-7731

Conversation

@FrankYang0529

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #7731

Rationale for this change

Rust core exposes Operator::copier() (a Copier handle that drives a long-running copy step by step), but it was missing from both the C and Go bindings, so Go users only had the one-shot Operator.Copy. This adds it.

What changes are included in this PR?

  • C binding: opendal_operator_copier / opendal_operator_copier_with, plus an opendal_copier handle with opendal_copier_next / _abort / _free and matching result types.
  • Go binding: a Copier type with Operator.Copier(src, dest, ...), Next() (uint, bool, error), Abort() and Close(). Copy-option building is refactored into a shared helper reused by both Copy and Copier.

Are there any user-facing changes?

New Operator.Copier API in the Go binding (and the underlying opendal_operator_copier* C functions). No breaking changes.

AI Usage Statement

Claude Code with Opus 4.8.

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. releases-note/feat The PR implements a new feature or has a title that begins with "feat" labels Jun 11, 2026
Comment thread bindings/go/copier.go

@erickguan erickguan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments on C binding firstly.

Comment thread bindings/c/include/opendal.h Outdated
Comment thread bindings/c/include/opendal.h
Comment thread bindings/c/include/opendal.h Outdated
Comment thread bindings/c/include/opendal.h
Comment thread bindings/c/src/copier.rs
if !ptr.is_null() {
drop(Box::from_raw((*ptr).inner as *mut core::blocking::Copier));
drop(Box::from_raw(ptr));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set ptr = nullptr?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, setting (*ptr).inner = NULL wouldn't add protection. The ptr is passed by value we can't null out the caller's own pointer. Changing the signature to opendal_copier ** would allow that, but all existing *_free functions in this binding (operator/reader/writer/lister) follow the same by-value pattern, so I kept it consistent.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you that (*ptr).inner = NULL wouldn't add protection. My C pointer story told me that setting some nullptr really helps debugging when things goes south.

But this is beyond the PR. So I will only recommend this.

Signed-off-by: PoAn Yang <payang@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

new feature: support Copier in the Go binding

3 participants