Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bindings/go): Add full native support from C to Go. #4886

Merged
merged 1 commit into from
Jul 13, 2024

Conversation

yuchanns
Copy link
Member

PR for #4848.

Let's rock!

I'm so excited that I can't help but complete it all at once. If this is too big to review, I can split it into smaller chunks.

  • Full implementation on top of C binding.
  • All behavior tests except those not supported by C binding yet. writer, read_with, eg.
  • Documentation for all APIs.

NOTE: this PR contains two experimental services memory and aliyun-drive to show how it works for behavior test purposes. Officially distributions need to be managed by @Xuanwo.

@yuchanns
Copy link
Member Author

yuchanns commented Jul 12, 2024

Bindings Go CI failed because the Go version is lower than 1.22.4 (1.20).

And considering 1.20 is out of maintenance, I think it is time to update to the latest version.

Each major Go release is supported until there are two newer major releases. For example, Go 1.5 was supported until the Go 1.7 release, and Go 1.6 was supported until the Go 1.8 release. We fix critical problems, including critical security problems, in supported releases as needed by issuing minor revisions (for example, Go 1.6.1, Go 1.6.2, and so on).

IMO we need to update the CI configuration because it is tailored for CGO.

Here is an example from my POC. It is really simple and easy.

@Xuanwo
Copy link
Member

Xuanwo commented Jul 12, 2024

And considering 1.20 is out of maintenance, I think it is time to update to the latest version.

Great, welcome to bump the go version in a new PR.

go test -bench=. -tags dynamic .
```bash
# Run all tests
CGO_ENABLE=0 go test -v -run TestBehavior
Copy link
Member

Choose a reason for hiding this comment

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

CGO_ENABLE=0!

bindings/go/reader.go Outdated Show resolved Hide resolved
@Xuanwo
Copy link
Member

Xuanwo commented Jul 12, 2024

This PR is outstanding overall! Excellent implementation, well-documented, and comprehensive tests (fully integrated testing). This is the best PR I've encountered this year!

Let's first address the CI and merge it into the main branch, then we can refine the API naming and other details.

@@ -17,12 +17,22 @@

module opendal.apache.org/go
Copy link
Member

Choose a reason for hiding this comment

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

Let's use github.com/apache/opendal/bindings/go so users can use go binding from git now.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure whether go support get sub directory.

Copy link
Member Author

Choose a reason for hiding this comment

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

image
Oh it doesn't work.

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't work since we are now pointintg to opendal.apache.org/go. After we change our mod to github.com/apache/opendal/bindings/go. It should work.

@Xuanwo
Copy link
Member

Xuanwo commented Jul 12, 2024

Ok, seems the ci changes need to go along with this PR.

@Zheaoli
Copy link
Member

Zheaoli commented Jul 12, 2024

Here's my personal thought.

The original Go binding is a full-function and cross-platform binding. The new Go binding has a good tech design and the ability to extend the function. But for now, I think we need a lot of time to solve some issues, such as binary release and distribution and cross-platform test(for now, I believe we specialize in Linux), keep the service we support is same with the old Go bindings.

So I think maybe we can make this feature as experimental and we add a new directory binding/go-ffi and remove the binding/go-ffi when the new Go binding is ready?

@yuchanns
Copy link
Member Author

seems the ci changes need to go along with this PR.

Yes. I closed it.

@yuchanns
Copy link
Member Author

yuchanns commented Jul 12, 2024

So I think maybe we can make this feature as experimental and we add a new directory binding/go-ffi and remove the binding/go-ffi when the new Go binding is ready?

I'm ok with that. But I don't think the old version is full functional. Seems it only implements read and write.

@Zheaoli
Copy link
Member

Zheaoli commented Jul 12, 2024

I'm ok with that. But I don't think the old version is full functional. Seems it only implements read and write.

New Go Binding!

Signed-off-by: Hanchin Hsieh <me@yuchanns.xyz>
@yuchanns
Copy link
Member Author

Benchmark is in absence. I should add one Later.

@Xuanwo
Copy link
Member

Xuanwo commented Jul 13, 2024

Hi, @Zheaoli, Thanks a lot for raising your concern.

The original Go binding is a full-function and cross-platform binding.

This is incorrect. In fact, it cannot even be used with go get.

But for now, I think we need a lot of time to solve some issues, such as binary release and distribution and cross-platform test(for now, I believe we specialize in Linux), keep the service we support is same with the old Go bindings.

This is true. I have a feeling that we will finally reintroduce CGO support for other platforms. It would be great if someone could take on the task of making the Go bindings cross-platform and fully functional. However, if no one is interested, I'm satisfied with the Go bindings working on Linux platforms for now.

So I think maybe we can make this feature as experimental and we add a new directory binding/go-ffi and remove the binding/go-ffi when the new Go binding is ready?

The old Go binding has never been usable, published, or maintained. The most recent change to the Go binding was four months ago, with the latest meaningful update occurring on October 21, 2023. I prefer not to keep the old go binding unless someone steps up to help maintain it.

Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, perfect PR!

@Xuanwo
Copy link
Member

Xuanwo commented Jul 13, 2024

Hi, @Zheaoli, would you like to leave a final comment?

Copy link
Member

@Zheaoli Zheaoli left a comment

Choose a reason for hiding this comment

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

LGTM

@Xuanwo Xuanwo merged commit bf15cec into apache:main Jul 13, 2024
28 checks passed
@yuchanns yuchanns deleted the go-binding-native branch July 13, 2024 05:41
@yuchanns yuchanns mentioned this pull request Jul 14, 2024
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants