serve

package
v0.46.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func Handler(maxRequestBytes int64, limits engine.Limits) http.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

func NewCommand() *cobra.Command

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

func Run(argv []string) int

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.

Types

type ServeOptions

type ServeOptions struct {
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	IdleTimeout  time.Duration
	Limits       engine.Limits
}

ServeOptions holds timeout and engine configuration for the HTTP server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL