server

package
v0.1.0-dev.20260904020137 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package server is the HTTP/2 wire listener for op runs (architecture 2.7) — it bridges a remote consumer to a run's in-process op.ControlPlane over REST commands and Server-Sent Events, so the whole bidirectional channel is drivable with curl.

A run registers its plane under a run id (Router.Register); the Router is a stateless run-id → plane lookup, so commands and the event stream are independent across the same or different connections. Three endpoints:

  • POST /v1/runs/{runID}/commands — body {"command": "pause"|"stop"|"step", "request_id"?}; the JSON response body is the response frame (the resulting op.RunStatus, or an error).
  • GET /v1/runs/{runID}/events — a text/event-stream the run pushes onto (the REGISTER → EVENT axis).
  • GET /v1/runs/{runID} — the current op.RunStatus (a plain poll).

The handler is served over cleartext HTTP/2 (h2c) so a single connection multiplexes the SSE stream and command POSTs as independent streams; HTTP/1.1 clients work too (the endpoints are transport-agnostic).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router routes HTTP requests to registered runs' control planes.

One router can front many concurrent runs; each registers its plane under a run id. The zero value is not usable — construct via NewRouter.

func NewRouter

func NewRouter() *Router

NewRouter returns an empty control-plane HTTP router.

Returns:

func (*Router) Handler

func (s *Router) Handler() http.Handler

Handler returns the HTTP handler serving the control endpoints, wrapped for cleartext HTTP/2 (h2c).

Mount it on an *http.Server (or an [httptest.Server]); it also handles HTTP/1.1 transparently.

Returns:

  • `http.Handler`: the h2c-wrapped router.

func (*Router) Register

func (s *Router) Register(runID string, plane *op.ControlPlane, status func() op.RunStatus) func()

Register makes `plane` reachable under `runID` and returns an unregister func.

The caller (a run's driver) registers when a run starts and calls the returned func when it ends. `status` is the run's current-status accessor — typically [GraphExecutor.RunStatus] as a method value — read by the status endpoint and to reject a command on a run that has already reached a terminal phase.

Parameters:

  • `runID`: the id the run is addressed by on the wire.
  • `plane`: the run's control plane.
  • `status`: the run's current-op.RunStatus accessor.

Returns:

  • `func()`: the unregister; idempotent.

Jump to

Keyboard shortcuts

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