controlplane

package
v0.116.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 16 Imported by: 0 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

Index

Constants

View Source
const CapabilityEmailWait = "email_wait"

CapabilityEmailWait declares that this runner runs `email_wait` nodes: it reads the run inbox and derives the text, links and code of a message.

View Source
const CapabilityFormBody = "form_body"

CapabilityFormBody declares that request nodes send `body_encoding: form` bodies form-encoded. An older runner would send them as JSON.

View Source
const CapabilitySecretOutputs = "secret_outputs"

CapabilitySecretOutputs declares that this runner masks secret node outputs. The control plane refuses a job whose flow declares one to a claim without it.

Variables

View Source
var ErrNoJobAvailable = errors.New("no runner job available")

Functions

func Capabilities added in v0.81.0

func Capabilities() []string

Capabilities lists what this runner build supports, declared on every claim.

func FlowExecutionResultToPayload

func FlowExecutionResultToPayload(result *spi.FlowExecutionResult) (map[string]any, error)

func IsTransient added in v0.70.0

func IsTransient(err error) bool

IsTransient reports whether err is a control-plane failure expected to clear on retry: a 5xx, 429 or edge 404 status, a network error, or a request deadline. A control plane redeploy produces these for a few seconds; the edge 404 is the proxy answering while it reroutes, so its body has no API error code. A 404 with a code, such as RUNNER_JOB_NOT_FOUND after a workspace delete, is the API saying the job is gone, and no retry can change that. Callers escalate a transient failure that persists.

func RetryTransient added in v0.114.0

func RetryTransient(
	ctx context.Context,
	backoff Backoff,
	operation string,
	attempt func(context.Context) error,
) error

RetryTransient calls attempt until it succeeds, fails with an error that IsTransient rejects, or ctx ends, waiting by backoff between attempts. The deadline of ctx is the whole retry budget; the HTTP client bounds each attempt. It returns the last attempt's error, joined to the one before it when the budget ended during that attempt.

Types

type APIErrorResponse

type APIErrorResponse struct {
	Errors []struct {
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"errors"`
}

type Backoff added in v0.114.0

type Backoff struct {
	Initial time.Duration
	Max     time.Duration
}

Backoff spaces the attempts of a control-plane call that failed transiently: the first retry waits Initial, each later one twice the previous, up to Max. A zero field takes the default of 200 ms doubling to 5 s.

type ClaimNextRequest

type ClaimNextRequest struct {
	RunnerID         string    `json:"runner_id"`
	BootID           uuid.UUID `json:"boot_id"`
	MaxParallelFlows int       `json:"max_parallel_flows"`
}

type ClaimedJob

type ClaimedJob struct {
	JobID           uuid.UUID                      `json:"job_id"`
	ExecutionID     uuid.UUID                      `json:"execution_id"`
	FlowID          uuid.UUID                      `json:"flow_id"`
	LeaseExpiresAt  time.Time                      `json:"lease_expires_at"`
	FlowDefinition  json.RawMessage                `json:"flow_definition"`
	Inputs          map[string]any                 `json:"inputs"`
	SecretInputKeys []string                       `json:"secret_input_keys,omitempty"`
	ReferencedFlows flowpkg.ReferencedFlowRegistry `json:"referenced_flows,omitempty"`
	// JobToken is set by a self-hosted claim. A one-shot Job gets it from its own claim.
	JobToken string `json:"job_token,omitempty"`
	// MaxHTTPCallsPerExecution is the organization's HTTP call limit. Zero, from a
	// control plane that does not send it, records calls without a limit.
	MaxHTTPCallsPerExecution int `json:"max_http_calls_per_execution,omitempty"`
	// TraceContext is the claim's W3C trace context; old control planes omit it.
	// The runner sends it on events, complete and webhook-requests calls for this job.
	TraceContext spi.TraceContext `json:"trace_context"`
}

func (*ClaimedJob) UnmarshalJSON

func (j *ClaimedJob) UnmarshalJSON(data []byte) error

type Client

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

func NewJobClient added in v0.52.0

func NewJobClient(baseURL, jobToken string, timeout time.Duration) *Client

func NewRunnerClient added in v0.52.0

func NewRunnerClient(config Config) *Client

func (*Client) ClaimNext

func (c *Client) ClaimNext(ctx context.Context, request ClaimNextRequest) (*ClaimedJob, error)

func (*Client) Complete

func (c *Client) Complete(ctx context.Context, jobID uuid.UUID, request CompleteJobRequest) error

Complete reports the job's final status. It retries a transient failure (a 5xx, 429, edge 404, network error or attempt timeout) until ctx ends, so the deadline of ctx is the completion budget, and stops at once on any other answer. Every attempt sends the same body. Only the control plane's job-token path (Cloud and ephemeral jobs) recognises it as a repeat of a completion that already landed. The runner-API-key path that a self-hosted daemon uses does not yet: a retry after a lost or timed-out response gets 409 RUNNER_JOB_COMPLETION_REJECTED for a job that is already complete, until echopoint gives runnerJobService.Complete the same digest replay.

func (*Client) Heartbeat

func (c *Client) Heartbeat(ctx context.Context, request HeartbeatRequest) ([]HeartbeatResult, error)

func (*Client) SendJobEvents

func (c *Client) SendJobEvents(
	ctx context.Context,
	jobID uuid.UUID,
	request SendJobEventsRequest,
) (*SendJobEventsResponse, error)

type CompleteJobRequest

type CompleteJobRequest struct {
	RunnerID          string          `json:"runner_id"`
	BootID            uuid.UUID       `json:"boot_id"`
	Status            string          `json:"status"`
	StartedAt         time.Time       `json:"started_at"`
	CompletedAt       time.Time       `json:"completed_at"`
	DurationMs        int64           `json:"duration_ms"`
	Result            *map[string]any `json:"result,omitempty"`
	ErrorMessage      *string         `json:"error_message,omitempty"`
	ErrorCode         *string         `json:"error_code,omitempty"`
	LastEventSequence *int64          `json:"last_event_sequence,omitempty"`
}

type Config

type Config struct {
	BaseURL        string
	OrganizationID string
	RunnerAPIKey   string
	RequestTimeout time.Duration
}

type HeartbeatRequest

type HeartbeatRequest struct {
	RunnerID         string      `json:"runner_id"`
	BootID           uuid.UUID   `json:"boot_id"`
	MaxParallelFlows int         `json:"max_parallel_flows"`
	JobIDs           []uuid.UUID `json:"job_ids"`
}

type HeartbeatResult

type HeartbeatResult struct {
	JobID          uuid.UUID  `json:"job_id"`
	Status         string     `json:"status"`
	LeaseExpiresAt *time.Time `json:"lease_expires_at"`
}

type RunnerProgressEvent

type RunnerProgressEvent struct {
	Sequence int64         `json:"sequence"`
	Type     spi.EventType `json:"type"`
	// Payload is the event-type-specific body, marshalled as a JSON object.
	// It is a typed struct at the call site (see internal/runtime payloads).
	Payload any `json:"payload"`
}

type SendJobEventsRequest

type SendJobEventsRequest struct {
	RunnerID string                `json:"runner_id"`
	BootID   uuid.UUID             `json:"boot_id"`
	Events   []RunnerProgressEvent `json:"events"`
}

type SendJobEventsResponse

type SendJobEventsResponse struct {
	LastAcceptedSequence int64 `json:"last_accepted_sequence"`
}

type StatusError added in v0.70.0

type StatusError struct {
	StatusCode int
	// Code is the control plane's API error code. It is empty when the body
	// carries none, as in an answer from the edge proxy instead of the API.
	Code   string
	Detail string
}

StatusError is a non-success HTTP status returned by the control plane.

func (*StatusError) Error added in v0.70.0

func (e *StatusError) Error() string

Jump to

Keyboard shortcuts

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