[Store] Add Go language bindings for Mooncake Store via C API#1659
[Store] Add Go language bindings for Mooncake Store via C API#1659jiangyukunok wants to merge 1 commit intokvcache-ai:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly expands the interoperability of Mooncake Store by introducing official Go language bindings. This allows developers to leverage the high-performance, RDMA-capable distributed key-value store directly from their Go applications. The changes encompass the full spectrum of client-side operations, from basic data manipulation to advanced features like zero-copy transfers, all integrated with the existing C++ core via a new C API layer. The update also includes necessary build system adjustments and Dockerfile improvements to facilitate development and deployment across different architectures. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces Go language bindings for the Mooncake Store, enabling Go applications to interact with the store. The changes are comprehensive, including a C API layer, a Go wrapper using CGo, build system updates, and example code. The implementation correctly handles CGo memory management and provides a clean interface. My review focuses on improving portability, maintainability, and demonstrating best practices. I've identified a potential portability issue with the use of the long type in the C API, and suggested improvements to the Dockerfile and the Go example code for better maintainability and correctness.
c0ccdb5 to
829d4d1
Compare
cf6a861 to
8130442
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a C ABI surface for Mooncake Store and a new Go module that uses cgo to call that C API, enabling Go applications to use core Store operations (setup/init/health, put/get, batch operations, remove, hostname, and buffer registration). It also wires Go bindings into the top-level build via an optional CMake target, updates CI to run Go tests, and updates the devcontainer to install Go on both amd64/arm64.
Changes:
- Added
store_c.h/store_c.cppC API wrapper aroundmooncake::RealClientand built it intolibmooncake_store. - Added Go bindings (
mooncakestorepackage), example program, and unit/integration tests. - Added
WITH_STORE_GOCMake option + CI workflow steps + devcontainer updates to support building/testing Go bindings.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| mooncake-store/src/store_c.cpp | Implements the C ABI wrapper around RealClient for lifecycle/ops/batch/buffer registration |
| mooncake-store/src/CMakeLists.txt | Adds store_c.cpp to the Mooncake Store library sources |
| mooncake-store/include/store_c.h | Declares the C ABI contract for the new bindings |
| mooncake-store/go/mooncakestore/store.go | Go API layer calling into store_c.h via cgo |
| mooncake-store/go/mooncakestore/config.go | Go-side replication config types/defaults |
| mooncake-store/go/mooncakestore/errors.go | Go error definitions for the binding layer |
| mooncake-store/go/mooncakestore/store_test.go | Unit + integration tests for Go bindings (currently mixed in one file) |
| mooncake-store/go/examples/basic/main.go | Example Go application using the bindings |
| mooncake-store/go/go.mod | Defines the Go module and Go language version |
| mooncake-store/go/build.sh | Build helper wiring include/link flags for cgo and example build |
| CMakeLists.txt | Adds WITH_STORE_GO option and custom target to build Go bindings |
| .github/workflows/ci.yml | Runs Go binding unit + integration tests in CI |
| .devcontainer/Dockerfile | Installs Go (amd64/arm64) and additional deps for local dev |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
a011d94 to
37027c3
Compare
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
store_c.cpp is a thin forwarding layer, it's fully exercised by the Go integration tests, which passed; |
|
I think it is important. How to publish a Go package and expose its APIs? |
|
LGTM. But I think we can opt for current organization. (mooncake-store => go => mooncakestore) |
There was a problem hiding this comment.
Move test files to a separate directory?
There was a problem hiding this comment.
We can spilt this feature into two parts (1) support mooncake store c API. (2) support GO
e1fcbc4 to
a148cdd
Compare
Description
Add Go language bindings for Mooncake Store, enabling Go programs to use Store operations (put, get, batch, zero-copy, buffer registration)
The structure of changes from top to bottom:
Also added
WITH_STORE_GObuild option to provide flexibilities.Also updated the outdated
.devcontainer/Dockerfileto have arm64 support.Also added unit tests and integration tests.
Module
mooncake-transfer-engine)mooncake-store)mooncake-ep)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-pg)mooncake-rl)Type of Change
How Has This Been Tested?
Build verification: store_c.cpp compiles as part of libmooncake_store via CMake with WITH_STORE_GO=ON.
Nil-safety tests (TestNilStoreOperations, TestNewAndClose): verify safe behavior on nil handles and double-close. These run without a cluster.
Integration tests (TestPutGetRoundTrip, TestBatchExists, TestRemoveAll, TestHostname, TestReplicateConfig):
from CI test:
Checklist
./scripts/code_format.shbefore submitting.