Documentation
¶
Overview ¶
Package deploy reads a workly.yaml, which declares queues, workflows and schedules, and works out the changes that make a server match it. The CLI's validate, plan and deploy commands are built on it.
Index ¶
Constants ¶
const Version = 1
Version is the file format version this package reads.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change struct {
Kind string // "queue", "workflow" or "schedule"
Name string
Action Action
// Diffs lists the settings an update changes.
Diffs []Diff
// Paused is set for an existing queue or schedule that is paused.
// Deploying leaves it paused.
Paused bool
// Body is the PUT request body: an api.QueueConfig, api.WorkflowConfig
// or api.ScheduleConfig. Deletes have none.
Body any
// Failed counts the failed tasks a queue's delete takes with it.
Failed int
}
Change is what deploying does to one declared queue, workflow or schedule.
type Default ¶ added in v0.4.1
Default is a ${NAME:-value} reference whose variable wasn't set (or was empty), so value was used for it in Field.
type Diff ¶
Diff is one changed setting. Change reads "old → new", or for header values and bodies, which may hold secrets, just "changed", "added" or "removed".
type File ¶
type File struct {
Path string
Queues []Queue
Workflows []Workflow
Schedules []Schedule
HasQueues, HasWorkflows, HasSchedules bool
// Prune deletes what a managed section leaves out (prune: true).
Prune bool
// Defaults lists the ${NAME:-default} references that took their
// default, in file order, so plan can show them: a variable CI forgot
// to set would otherwise deploy a local default without a word.
Defaults []Default
}
File is a valid workly.yaml. A section left out of the file isn't managed by it (HasQueues, HasWorkflows, HasSchedules); an empty one declares nothing.
func Load ¶
Load reads and validates the file at path, replacing ${NAME} in values with environment variables looked up by getenv (os.LookupEnv in the CLI).
func (*File) Plan ¶
func (f *File) Plan(queues []api.Queue, workflows []api.Workflow, schedules []api.Schedule) (Plan, error)
Plan compares the file with the queues, workflows and schedules on the server. With prune, it fails if a queue it would delete still has tasks to deliver: those tasks would be lost, and the next enqueue would bring the queue back anyway.
type InvalidError ¶
InvalidError lists every problem found in a file.
func (*InvalidError) Error ¶
func (e *InvalidError) Error() string
type Plan ¶
type Plan struct {
// Changes has every declared queue, then every declared workflow, then
// every declared schedule, in file order, unchanged ones included. That
// is the order they are applied in, so a schedule's workflow exists by
// the time the schedule is put. With prune, the deletes follow, in the
// reverse order (schedules, workflows, queues), so nothing is deleted
// while something left on the server still points at it.
Changes []Change
// Undeclared lists the schedules on the server the file doesn't
// declare, if it has a schedules section and doesn't prune. Deploying
// leaves them alone. Queues aren't listed: enqueueing creates them, so
// most aren't in a file.
Undeclared []string
// UndeclaredWorkflows does the same for workflows.
UndeclaredWorkflows []string
}
type Problem ¶
Problem is one thing wrong with a file: where, which field (a path such as schedules.nightly.cron) and what.
type Queue ¶
type Queue struct {
Name string
Config api.QueueConfig
// contains filtered or unexported fields
}
Queue is a declared queue: Config is the PUT body, settings what it becomes with defaults applied.
type Schedule ¶
type Schedule struct {
Name string
Config api.ScheduleConfig
// contains filtered or unexported fields
}
type Workflow ¶ added in v0.4.0
type Workflow struct {
Name string
Config api.WorkflowConfig
// contains filtered or unexported fields
}