PR Description: Go SDK for BoxLite #202
Conversation
a5738a4 to
35a2f60
Compare
|
@DorianZheng Please have a look |
@qidi1 Sorry for the late response—I’m reviewing it now. I’m impressed that you implemented this in such a short time. |
| @@ -0,0 +1,360 @@ | |||
| // BoxLite Go SDK - Rust Bridge Layer | |||
There was a problem hiding this comment.
@qidi1 Do you think we can reuse the C SDK? Or can we extract common codes for both Go and C SDK
There was a problem hiding this comment.
Thanks for raising this, @DorianZheng! I've been thinking about the architecture carefully.
Options Considered
Option A: Fully Reuse C SDK
Pros: Single source of truth, lower maintenance
Cons: C SDK becomes the "lowest common denominator" for all languages; changes require considering all consumers
Option B: Keep Separate (Current Implementation)
Pros: Full independence for each SDK
Cons: Duplicate FFI code, double maintenance cost, and Go's CGO goes through C ABI anyway — so the "independence" doesn't unlock much optimization
Option C: Extract a Shared FFI Core (boxlite-ffi-core)
Pros:
- Shared logic (error handling, JSON serialization, runtime management) lives in one place
- Each SDK can still extend with language-specific features if needed
- Clean architectural boundary: core handles "Rust → C ABI", each SDK handles "C ABI → language wrapper"
- Gradual evolution: if needs diverge later, we can add SDK-specific code without touching core
Cons:
- Requires a one-time refactor to extract the core
- Need to design the core API boundary carefully
My Preference
I lean toward Option C — extracting a boxlite-ffi-core crate.
Looking at the current code, most of it is shared logic (error handling, string helpers, JSON serialization). The extraction should be straightforward — it's mostly moving code around, no logic changes needed.
There was a problem hiding this comment.
@qidi1 Good analysis. I agree with you. How about just boxlite-ffi
|
cc @Wenrh2004. Could you take a look on this PR |
95f1561 to
0f904bc
Compare
|
@DorianZheng @Wenrh2004 Please have a look |
Signed-off-by: 季扎 <[email protected]>
8ccc18e to
1277212
Compare
Signed-off-by: 季扎 <[email protected]>
1277212 to
f74a7a2
Compare
#198
Introduces the Go SDK, enabling Go applications to create and manage BoxLite VMs.
What's Included
Phase 1 – Foundation
Phase 2 – Lifecycle Management
Client.CreateBox()/GetBox()/ListBoxes()/RemoveBox()Box.Start()/Stop()/Info()/Close()Concurrency Design
block_on()bridges CGO sync calls to async RustBoxliteRuntimeisSend + SyncwithArc<RwLock>protectionBuild System
Makefile(macOS + Linux auto-detection)libkrunTesting
Files Changed
sdks/go/– New Go SDK.github/workflows/lint.yml– Added Go linting