control

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package control implements the loom.v1.Control gRPC service — the controller<->agent control plane (DESIGN.md §8). This is the skeleton: the coordination RPCs (Health/Register/Capabilities/TimeSync) work; the flow lifecycle RPCs are inherited as Unimplemented until the agent fills them in.

Index

Constants

View Source
const APIVersion = 1

APIVersion is the control-plane wire version this build speaks (ADR-0021). Bump it on a breaking proto change so peers can detect a mismatch.

Variables

This section is empty.

Functions

func Dial

func Dial(addr string, opts ...DialOption) (loomv1.ControlClient, *grpc.ClientConn, error)

Dial connects a control client to addr (host:port). It uses insecure transport for now; optional mTLS (ADR-0014) is added later. Pass WithToken to authenticate against an agent that requires a control-plane token. The returned connection must be closed by the caller.

func NewGRPCServer

func NewGRPCServer(s *Server) *grpc.Server

NewGRPCServer builds a *grpc.Server with the control service registered. When the Server has an auth token set, token-checking unary/stream interceptors are installed.

func Sync

Sync performs one four-timestamp time-sync exchange against an agent and returns the estimated clock offset and round-trip delay. The caller stamps t1 before the RPC and t4 after it; the agent stamps t2/t3 (see Server.TimeSync and the timesync package).

Types

type DialOption

type DialOption func(*dialConfig)

DialOption configures a control-plane dial.

func WithToken

func WithToken(token string) DialOption

WithToken attaches a shared bearer token (ADR-0014) to every RPC on the connection. An empty token is a no-op, so callers can pass it unconditionally.

type Option

type Option func(*Server)

Option configures a Server (ADR-0022). Apply at construction via NewServer.

func WithAuthToken

func WithAuthToken(token string) Option

WithAuthToken sets the shared control-plane token (ADR-0014). When non-empty, NewGRPCServer installs interceptors that reject any RPC lacking a matching bearer token; empty leaves the plane open.

func WithComponents

func WithComponents(c *components.Components) Option

WithComponents sets the datapath/generator/scheduler/payload registries this agent builds flows from and advertises via Capabilities. Defaults to components.Default().

func WithMaxFlows

func WithMaxFlows(n int) Option

WithMaxFlows caps concurrently configured flows; Configure returns ResourceExhausted past the cap. n <= 0 removes the limit (not recommended on a reachable agent).

func WithTelemetryInterval

func WithTelemetryInterval(d time.Duration) Option

WithTelemetryInterval sets how often StreamTelemetry emits samples (0 = 1s).

type Server

type Server struct {
	loomv1.UnimplementedControlServer
	// contains filtered or unexported fields
}

Server implements loomv1.ControlServer. Flow-lifecycle RPCs (Configure/Arm/Start/Stop/Destroy/StreamTelemetry) are inherited from UnimplementedControlServer and return codes.Unimplemented for now.

func NewServer

func NewServer(version string, opts ...Option) *Server

NewServer returns a control Server reporting the given version, configured by opts.

func (*Server) Arm

Arm is a no-op for now (receivers/ephemeral ports arrive later).

func (*Server) AuthEnabled

func (s *Server) AuthEnabled() bool

AuthEnabled reports whether a control-plane token is configured.

func (*Server) Capabilities

Capabilities reports what this agent can do, from its configured components.

func (*Server) Configure

Configure builds and stores a flow, returning its id. Ephemeral data-port assignment is a later step; data_port is 0 for now.

func (*Server) Destroy

Destroy tears a flow down and releases its datapath.

func (*Server) Health

Health reports liveness, build version, and the wire API version.

func (*Server) Register

Register enrolls an agent. Minimal for now: the agent id is echoed as the session. Token/mTLS enrollment (ADR-0014) arrives with the controller/agent.

func (*Server) Start

Start runs a configured flow, optionally at a scheduled time (start_at) on this agent's clock so flows across agents begin in lockstep.

func (*Server) Stop

Stop cancels a running flow.

func (*Server) StreamTelemetry

func (s *Server) StreamTelemetry(req *loomv1.TelemetryRequest, stream loomv1.Control_StreamTelemetryServer) error

StreamTelemetry streams a flow's telemetry until the flow finishes or the client disconnects. When the flow was started with a report interval I, samples are anchored to the gate: one per boundary at startAt + k*I, each carrying that interval's delta (the controller is then a pure summer, with no second clock). With no interval (legacy controllers, report_interval_nanos == 0) it falls back to a free-running cadence.

func (*Server) TimeSync

TimeSync stamps t2 on receipt and t3 on send for the four-timestamp exchange.

Jump to

Keyboard shortcuts

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