Documentation
¶
Overview ¶
Package serve is the command surface for running dtctl as a server on top of pkg/engine. Each protocol is its own subcommand — `dtctl serve http` today, room for `dtctl serve mcp` and others without redefining what bare `serve` means. This file holds the parent command and the standalone dispatch; each protocol lives in its own file (http.go).
The servers here are reference implementations. They carry no authentication of their own: every request brings the tenant token it runs with, and listeners bind to localhost by default. A real deployment puts its own authentication, TLS, and rate limiting in front (or embeds pkg/engine directly instead of shipping one of these servers).
Index ¶
Constants ¶
const DevelopmentFeature = "serve"
DevelopmentFeature is the stability opt-in key for the `dtctl serve` command surface. Server mode is still taking shape — the request/response contract and the one-invocation-at-a-time concurrency model are subject to change — so it is a development-tier feature: released builds do not register the command unless the operator opts in with `dtctl config set development.serve on` or DTCTL_DEVELOPMENT=serve.
pkg/engine now enforces per-request admission control and a duration budget (see engine.Limits, engine.DefaultLimits); what remains open is documented in docs/dev/SERVICE_ENGINE_DESIGN.md's "Known limitations".
The gate covers the *command* only. pkg/engine stays importable: embedding it is a deliberate Go API choice made at compile time, not a surface an end user can stumble into. Promote serve out of the development tier when its contract settles.
Variables ¶
This section is empty.
Functions ¶
func Enabled ¶
func Enabled() bool
Enabled reports whether the `dtctl serve` command surface is opted into.
main needs this *before* the command pipeline runs, because a server must start outside the per-invocation lock (see Run). Inside the pipeline the registration stage makes the same decision for the tree.
func Handler ¶
Handler returns the HTTP server's http.Handler:
POST /v1/execute — run one dtctl command line (body: executeRequest) GET /healthz — liveness probe
maxRequestBytes bounds the request body (virtual files travel inline). limits controls queue depth, duration, and output caps for each execution.
func NewCommand ¶
NewCommand builds the `dtctl serve` command tree. It lives outside package cmd because it imports pkg/engine, which imports cmd — main wires an instance onto the root via cmd.AddCommand for help/catalog visibility, and executes a standalone instance via Run (see there for why).
The parent itself is not runnable: naming the protocol is mandatory, so no single one is the silent default. Bare `dtctl serve` prints help and exits 0.
func Run ¶
Run executes `dtctl serve ...` standalone with the given arguments (everything after "serve") and returns the process exit code. main dispatches to it *before* the normal command pipeline: a server must run outside the per-invocation lock, because every request it accepts becomes an engine execution that has to acquire that lock — a server started inside an invocation would deadlock its own first request.