Documentation
¶
Index ¶
- Constants
- Variables
- func Capabilities() []string
- func FlowExecutionResultToPayload(result *spi.FlowExecutionResult) (map[string]any, error)
- func IsTransient(err error) bool
- func RetryTransient(ctx context.Context, backoff Backoff, operation string, ...) error
- type APIErrorResponse
- type Backoff
- type ClaimNextRequest
- type ClaimedJob
- type Client
- func (c *Client) ClaimNext(ctx context.Context, request ClaimNextRequest) (*ClaimedJob, error)
- func (c *Client) Complete(ctx context.Context, jobID uuid.UUID, request CompleteJobRequest) error
- func (c *Client) Heartbeat(ctx context.Context, request HeartbeatRequest) ([]HeartbeatResult, error)
- func (c *Client) SendJobEvents(ctx context.Context, jobID uuid.UUID, request SendJobEventsRequest) (*SendJobEventsResponse, error)
- type CompleteJobRequest
- type Config
- type HeartbeatRequest
- type HeartbeatResult
- type RunnerProgressEvent
- type SendJobEventsRequest
- type SendJobEventsResponse
- type StatusError
Constants ¶
const CapabilityContractNodes = "contract_nodes"
CapabilityContractNodes declares that this runner parses and executes `input` and `output` contract nodes (ADR-0037).
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.
const CapabilityFormBody = "form_body"
CapabilityFormBody declares that request nodes send `body_encoding: form` bodies form-encoded. An older runner would send them as JSON.
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 ¶
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
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 Backoff ¶ added in v0.114.0
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 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 NewRunnerClient ¶ added in v0.52.0
func (*Client) ClaimNext ¶
func (c *Client) ClaimNext(ctx context.Context, request ClaimNextRequest) (*ClaimedJob, error)
func (*Client) Complete ¶
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 HeartbeatRequest ¶
type HeartbeatResult ¶
type RunnerProgressEvent ¶
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