e0e362d700
SDK Tests / changes (push) Waiting to run
SDK Tests / Python SDK Tests (sandbox) (push) Blocked by required conditions
SDK Tests / CLI Quality (push) Blocked by required conditions
SDK Tests / CLI Tests (push) Blocked by required conditions
SDK Tests / Python SDK Quality (code-interpreter) (push) Blocked by required conditions
SDK Tests / Python SDK Quality (sandbox) (push) Blocked by required conditions
SDK Tests / Python SDK Tests (code-interpreter) (push) Blocked by required conditions
SDK Tests / JavaScript SDK Quality And Tests (code-interpreter) (push) Blocked by required conditions
SDK Tests / JavaScript SDK Quality And Tests (sandbox) (push) Blocked by required conditions
Deploy Docs Pages / build (push) Waiting to run
Deploy Docs Pages / deploy (push) Blocked by required conditions
Real E2E Tests / changes (push) Waiting to run
Real E2E Tests / Python E2E (docker bridge) (push) Blocked by required conditions
Real E2E Tests / Java E2E (docker bridge) (push) Blocked by required conditions
Real E2E Tests / JavaScript E2E (docker bridge) (push) Blocked by required conditions
Real E2E Tests / C# E2E (docker bridge) (push) Blocked by required conditions
Real E2E Tests / Go E2E (docker bridge) (push) Blocked by required conditions
Real E2E Tests / Real E2E CI (push) Blocked by required conditions
SDK Tests / Kotlin SDK Quality And Tests (sandbox) (push) Blocked by required conditions
SDK Tests / Kotlin SDK Quality And Tests (code-interpreter) (push) Blocked by required conditions
SDK Tests / C# SDK Quality And Tests (code-interpreter) (push) Blocked by required conditions
SDK Tests / C# SDK Quality And Tests (sandbox) (push) Blocked by required conditions
SDK Tests / Go SDK Quality And Tests (push) Blocked by required conditions
SDK Tests / SDK CI (push) Blocked by required conditions
3.2 KiB
3.2 KiB
Development Guide - execd
Getting Started
Prerequisites
- Go 1.24+ — match
go.mod - Make — build automation
- Docker/Podman — containerized testing (optional)
- Jupyter Server — required for integration tests
Setup
cd components/execd
go mod download
make build # → bin/execd
Project Structure
execd/
├── main.go # Entry point
├── Makefile # Build automation
├── Dockerfile # Container image
├── pkg/
│ ├── flag/ # CLI flag parsing
│ ├── web/
│ │ ├── router.go # Gin route registration
│ │ ├── controller/ # Request handlers
│ │ └── model/ # API request/response models
│ ├── runtime/ # Execution engine
│ │ ├── ctrl.go # Main controller
│ │ ├── jupyter.go # Jupyter kernel execution
│ │ ├── command.go # Shell command execution
│ │ └── bash_session.go # Pipe-based bash sessions
│ ├── jupyter/ # Jupyter HTTP/WebSocket client
│ ├── telemetry/ # OTLP metrics
│ ├── clone3compat/ # Linux clone3 seccomp workaround
│ └── log/ # Structured logger wrapper
└── tests/ # Integration test scripts
Key Patterns
- Controller pattern (
pkg/web/controller): thin Gin handlers that parse requests, validate, delegate to runtime, and stream responses via SSE. - Runtime controller (
pkg/runtime): dispatches to Jupyter, Command, or SQL executors; manages session lifecycle. - Hook-based streaming: execution results flow through hooks, decoupling runtime events from SSE serialization.
Testing
Unit Tests
go test ./pkg/...
go test -v -cover ./pkg/...
Integration Tests
Require a running Jupyter server:
export JUPYTER_URL=http://localhost:8888
export JUPYTER_TOKEN=your-token
go test -v ./pkg/jupyter/...
Common Tasks
Adding a New API Endpoint
-
Define request/response model in
pkg/web/model/. -
Add controller method in
pkg/web/controller/:
func (c *MyController) NewFeature() {
var req model.NewFeatureRequest
if err := c.Ctx.ShouldBindJSON(&req); err != nil {
c.Ctx.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
// ...
}
- Register route in
pkg/web/router.go:
myGroup := r.Group("/my-feature")
{
myGroup.POST("", withMyController(func(c *controller.MyController) { c.NewFeature() }))
}
Adding a Configuration Flag
- Declare variable in
pkg/flag/flags.go. - In
pkg/flag/parser.go, read env var first, then registerflag.*Varwith current value as default — flag overrides env. - Update
README.mdCLI Flags and Environment Variables tables.
Debugging SSE Streams
curl -N -H "Content-Type: application/json" \
-d '{"language":"python","code":"print(\"test\")"}' \
http://localhost:44772/code
-N disables buffering for real-time events.
Useful Commands
make fmt # gofmt
make golint # lint
make test # all tests
make build # binary → bin/execd