Documentation
¶
Overview ¶
Package conductor connects a worker process to RunnerQ Cloud.
The agent dials out over a WebSocket and answers the Cloud's requests from the engine's own storage backend; the Cloud never connects in and never holds database credentials. It is off the execution path: activities keep running if the Cloud or the agent fails, and it reconnects with backoff.
engine, _ := runnerq.Builder().Backend(backend).Build()
agent, err := conductor.Start(ctx, engine, conductor.Config{
URL: "wss://cloud.runnerq.dev",
APIKey: os.Getenv("RUNNERQ_CONDUCTOR_KEY"),
})
if err != nil { ... }
defer agent.Close(context.Background())
engine.Start(ctx)
Services that hold a backend themselves (RunnerQ Cloud's data plane) answer the same requests with a Handler, without a worker or connection.
The wire protocol is runnerq-spec's conductor protocol (protocol/conductor in github.com/runnerq/runnerq-spec).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent is a running connection to RunnerQ Cloud.
func Start ¶
Start validates cfg and connects in the background, so an unreachable Cloud never delays the worker. The agent stops when ctx ends or on Close.
func (*Agent) Close ¶
Close says goodbye (so the Cloud records a deploy, not a crash), closes the connection and waits for the agent to stop or ctx to end. Call it before stopping the engine.
type Config ¶
type Config struct {
// URL is the Cloud gateway, e.g. "wss://cloud.runnerq.dev". /v1/agent is
// appended when missing; http(s) maps to ws(s).
URL string
// APIKey authenticates the app. It is sent only in the Authorization
// header, never in the URL.
APIKey string
// AllowControl lets the Cloud run commands (cancel, retry, run now,
// reschedule, set priority, delete, signal). Off by default: read-only.
AllowControl bool
// MetadataOnly withholds payloads, results, errors and event details
// whatever mode the Cloud asks for; the Cloud cannot relax it.
MetadataOnly bool
// Labels are executor tags (region, deploy version) the Cloud filters and
// groups by, merged over WorkerConfig.Labels. Prefer WorkerConfig.Labels,
// which every way of reporting to the Cloud carries.
Labels map[string]string
// MaxConcurrentRequests bounds requests served at once (default 16);
// excess requests get "resource_exhausted" rather than queueing.
MaxConcurrentRequests int
// RequestTimeout bounds one request (default 30s).
RequestTimeout time.Duration
// MinReconnectDelay and MaxReconnectDelay bound the reconnect backoff
// (defaults 1s and 30s). Each wait is jittered by ±50%.
MinReconnectDelay time.Duration
MaxReconnectDelay time.Duration
Logger *slog.Logger
}
Config configures the agent.
type Error ¶
type Error struct {
Code string `json:"code"`
Message string `json:"message"`
Details map[string]any `json:"details,omitempty"`
}
Error is a failed request as sent on the wire.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the Cloud protocol's queries and commands from a storage backend, as an agent does, but without a worker engine or a connection.
Reads cover whatever the backend's queries cover (for Postgres, every queue in its schema); commands act on the backend's own queue. Handler checks no caller identity and applies no deadline or size limit: the caller authorizes requests, scopes the backend to what they may see, and sets deadlines and bounds answer sizes.
func NewHandler ¶
func NewHandler(backend storage.Storage, cfg HandlerConfig) *Handler
NewHandler returns a Handler for backend. It serves queries when backend implements storage.QueryStorage, and commands when it implements storage.CommandStorage, reports its queue and cfg allows them.
func (*Handler) Capabilities ¶
func (h *Handler) Capabilities() json.RawMessage
Capabilities describes what the handler serves as a JSON object keyed by message type, as in an agent's hello.
type HandlerConfig ¶
type HandlerConfig struct {
// AllowControl serves commands (cancel, retry, run now, reschedule, set
// priority, delete, signal) when the backend supports them and has a
// QueueName() string method; targets naming another queue fail.
AllowControl bool
}
HandlerConfig configures a Handler.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
wire
Package wire holds the Conductor protocol's types, generated from the runnerq-spec submodule's protocol/conductor/conductor.schema.json.
|
Package wire holds the Conductor protocol's types, generated from the runnerq-spec submodule's protocol/conductor/conductor.schema.json. |