Documentation
¶
Index ¶
Constants ¶
const PlanKindCommand = "command"
PlanKindCommand runs a command: its Params is a jobs.Command, the plan manager builds its Task.Job, and every run of it is reported with PlanRunStarted and PlanRunFinished.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Plan ¶ added in v0.4.0
type Plan struct {
ID string `json:"id"`
Metadata labels.Set `json:"metadata"`
Description string `json:"description"`
Kind string `json:"kind"` // a predefined kind, from which the plan manager builds the Task's Job
Params any `json:"params,omitempty"` // what the kind takes, as its constant says
Task *Task `json:"task"`
}
type PlanRun ¶ added in v0.7.0
type PlanRun struct {
ID string `json:"id"`
PlanID string `json:"plan_id"`
Source PlanRunSource `json:"source"`
State PlanRunState `json:"state"`
StartedAt time.Time `json:"started_at"`
EndedAt time.Time `json:"ended_at,omitzero"`
ExitCode int `json:"exit_code"` // for a kind with an exit status, like a command
OutputTail string `json:"output_tail,omitempty"`
LogPath string `json:"log_path,omitempty"`
Error string `json:"error,omitempty"`
}
PlanRun is one run of a plan, as of when it was reported. A retry or a requeue is a new run. LastRun returns the plan's latest one. A run of Trigger that a Cancel, Delete or Stop drops before it starts ends canceled, with the time of its Trigger as StartedAt and no log.
type PlanRunFinished ¶ added in v0.7.0
type PlanRunFinished struct {
PlanRun
}
PlanRunFinished is sent through the plan manager's MessageSender as a run ends.
func (PlanRunFinished) Kind ¶ added in v0.7.0
func (PlanRunFinished) Kind() string
type PlanRunSource ¶ added in v0.7.0
type PlanRunSource string
PlanRunSource says who started a run; a caller of Trigger may define values of its own.
const ( PlanRunSchedule PlanRunSource = "schedule" PlanRunManual PlanRunSource = "manual" )
type PlanRunStarted ¶ added in v0.7.0
type PlanRunStarted struct {
PlanRun
}
PlanRunStarted is sent through the plan manager's MessageSender as a run starts.
func (PlanRunStarted) Kind ¶ added in v0.7.0
func (PlanRunStarted) Kind() string
type PlanRunState ¶ added in v0.7.0
type PlanRunState string
const ( PlanRunRunning PlanRunState = "running" PlanRunSucceeded PlanRunState = "succeeded" PlanRunFailed PlanRunState = "failed" PlanRunCanceled PlanRunState = "canceled" )
type PlanStats ¶ added in v0.8.1
type PlanStats struct {
ID string `json:"id"`
Schedule string `json:"schedule"`
State string `json:"state"`
Progress float64 `json:"progress"`
StartedAt time.Time `json:"started_at"`
ExecutionTime time.Duration `json:"execution_time"`
Cooldown time.Duration `json:"cooldown"`
Retries uint `json:"retries"`
Labels labels.Set `json:"labels"`
Error string `json:"error"`
LastRun *PlanRun `json:"last_run,omitempty"` // as LastRun returns it, nil if it has not run
}
type PlanStatsOptions ¶ added in v0.8.1
type PlanStatsOptions struct {
Selector string `json:"selector,omitempty"` // a label selector over the plans' Metadata; empty is every plan
All bool `json:"all"` // also the plans whose job succeeded
}
PlanStatsOptions says which plans' stats the plan manager's Stats lists.
type PubsubMessage ¶
type PubsubMessage struct {
From string `json:"from"`
Topic string `json:"topic"`
Kind string `json:"kind"`
Payload any `json:"payload"`
}
PubsubMessage represents an event delivered through a subscription channel.
type SupervisorInitPolicy ¶ added in v0.6.9
SupervisorInitPolicy shapes how a service's init turn retries: MaxRetries bounds the attempts (0 one pass, -1 until ctx cancels), Delay is the backoff base, doubling up to MaxDelay.
type SupervisorMonitorPolicy ¶ added in v0.6.9
type SupervisorMonitorPolicy struct {
Interval time.Duration
MaxRetries int
RestartDelay time.Duration
}
SupervisorMonitorPolicy shapes the health monitor: Interval is the sweep cadence (0 disables monitoring), MaxRetries bounds in-process restarts per service (0 none - a liveness failure escalates immediately, -1 unlimited), RestartDelay pauses before each restart attempt.
type SupervisorStats ¶ added in v0.4.0
type SupervisorStats struct {
Name string
Initialized bool
InitializedAt time.Time
InitializationErr error
Started bool
StartedAt time.Time
StartErr error
Stopped bool
StoppedAt time.Time
StopErr error
HealthcheckedAt time.Time
HealthcheckErr error
LivenessErr error
Ready bool
ReadinessErr error
Restarts int
RestartedAt time.Time
InitDuration time.Duration
StartDuration time.Duration
StopDuration time.Duration
Source common.Service
}
func (*SupervisorStats) Healthcheck ¶ added in v0.4.0
func (s *SupervisorStats) Healthcheck() error
func (*SupervisorStats) Uptime ¶ added in v0.4.0
func (s *SupervisorStats) Uptime() time.Duration
type SupervisorStopPolicy ¶ added in v0.6.9
SupervisorStopPolicy shapes how a shutdown ends: Timeout bounds the whole stop, and the stop of each restart, after which what is left is forced; 0 leaves the bound to the caller's context.
type Task ¶ added in v0.8.1
type Task struct {
Job job.Job `json:"-"`
Ctx context.Context `json:"-"`
Params any `json:"params"`
Schedule string `json:"schedule"`
// Manual keeps the task registered without running it on its own: only Trigger does.
Manual bool `json:"manual,omitempty"`
Priority int `json:"priority"` // lower runs first; within one, in the order queued
// Exclusive runs it alone: it takes every slot, so it waits for the executions going on
// and nothing else starts until it ends. What a forced stop left running holds no slot.
Exclusive bool `json:"exclusive"`
Timeout time.Duration `json:"timeout,omitempty"`
RetryAttempts int `json:"retry_attempts,omitempty"`
RetryDelay time.Duration `json:"retry_delay,omitempty"`
// RequeueAttempts is how many times a failed execution, its retries used
// up, goes back to the queue. Unlike a retry it gives up its slot while
// it waits, and it counts on top: a task runs up to
// (RetryAttempts+1) * (RequeueAttempts+1) times.
RequeueAttempts int `json:"requeue_attempts,omitempty"`
// RequeueCooldown is how long a failed execution waits before going back to
// the queue.
RequeueCooldown time.Duration `json:"requeue_cooldown,omitempty"`
}
Task is what the task manager runs, and configuration only: the manager keeps its state of a task elsewhere, so a Task copies like any value.
func (*Task) ID ¶ added in v0.8.1
ID is the task's identity, its job's ID; look tasks up by ID only.
type TaskStats ¶ added in v0.8.1
type TaskStats struct {
executor.Stats
Requeues uint `json:"requeues"` // times the current firing went back to the queue
Cooldown time.Duration `json:"cooldown"` // what is left of the current RequeueCooldown
// Requeueing says the latest execution failed and the task waits to run again, cooling
// down or back in the queue. Its job stays failed meanwhile: that run did fail.
Requeueing bool `json:"requeueing"`
}
TaskStats is what the task's executor reports, plus what the task manager adds on top of it.