Documentation ¶
Index ¶
- Constants
- Variables
- func ApproveActionDep(p db.PGDBTX) func(*wf.TaskContext) error
- func BaseLink(baseURL *url.URL) func(target string, extras ...string) string
- func ConnectMaintenanceDB(ctx context.Context, cfg *pgx.ConnConfig, maintDB string) (*pgx.Conn, error)
- func CreateDBIfNotExists(ctx context.Context, cfg *pgx.ConnConfig) error
- func DropDB(ctx context.Context, cfg *pgx.ConnConfig) error
- func InitDB(ctx context.Context, conn string) error
- func LogOnlyMailer(header task.MailHeader, content task.MailContent) error
- func MigrateDB(conn string, downUp bool) error
- func RegisterReleaseWorkflows(ctx context.Context, h *DefinitionHolder, build *BuildReleaseTasks, ...) error
- func UnmarshalWorkflow(marshalled string, d *workflow.Definition) (map[string]any, error)
- type BuildReleaseTasks
- type DefinitionHolder
- type FailedToScheduleEntry
- type Listener
- type MetricsDB
- type PGListener
- func (l *PGListener) Logger(workflowID uuid.UUID, taskName string) workflow.Logger
- func (l *PGListener) TaskStateChanged(workflowID uuid.UUID, taskName string, state *workflow.TaskState) error
- func (l *PGListener) WorkflowFinished(ctx context.Context, workflowID uuid.UUID, outputs map[string]interface{}, ...) error
- func (l *PGListener) WorkflowStalled(workflowID uuid.UUID) error
- func (l *PGListener) WorkflowStarted(ctx context.Context, workflowID uuid.UUID, name string, ...) error
- type RunOnce
- type Schedule
- type ScheduleEntry
- type ScheduleType
- type Scheduler
- func (s *Scheduler) Create(ctx context.Context, sched Schedule, workflowName string, ...) (row db.Schedule, err error)
- func (s *Scheduler) Delete(ctx context.Context, id int) error
- func (s *Scheduler) Entries(ctx context.Context, workflowNames ...string) ([]ScheduleEntry, []FailedToScheduleEntry)
- func (s *Scheduler) Resume(ctx context.Context) error
- type Server
- type SiteHeader
- type Worker
- func (w *Worker) Resume(ctx context.Context, id uuid.UUID) error
- func (w *Worker) ResumeAll(ctx context.Context) error
- func (w *Worker) RetryTask(ctx context.Context, id uuid.UUID, name string) error
- func (w *Worker) Run(ctx context.Context) error
- func (w *Worker) StartWorkflow(ctx context.Context, name string, params map[string]interface{}, ...) (uuid.UUID, error)
- type WorkflowSchedule
Constants ¶
const DatetimeLocalLayout = "2006-01-02T15:04"
Variables ¶
var ErrScheduleNotFound = errors.New("schedule not found")
var (
ScheduleTypes = []ScheduleType{ScheduleImmediate, ScheduleOnce, ScheduleCron}
)
var Views = []*view.View{ { Name: "go-build/relui/http/server/latency", Description: "Latency distribution of HTTP requests", Measure: ochttp.ServerLatency, TagKeys: []tag.Key{ochttp.KeyServerRoute}, Aggregation: ochttp.DefaultLatencyDistribution, }, { Name: "go-build/relui/http/server/response_count_by_status_code", Description: "Server response count by status code", TagKeys: []tag.Key{ochttp.StatusCode, ochttp.KeyServerRoute}, Measure: ochttp.ServerLatency, Aggregation: view.Count(), }, { Name: "go-build/relui/db/query_latency", Description: "Latency distribution of database queries", TagKeys: []tag.Key{kDBQueryName}, Measure: mDBLatency, Aggregation: ochttp.DefaultLatencyDistribution, }, }
Views should contain all measurements. All *view.View added to this slice will be registered and exported to the metric service.
Functions ¶
func ApproveActionDep ¶
func ApproveActionDep(p db.PGDBTX) func(*wf.TaskContext) error
ApproveActionDep returns a function for defining approval Actions.
ApproveActionDep takes a single *pgxpool.Pool argument, which is used to query the database to determine if a task has been marked approved.
ApproveActionDep marks the task as requiring approval in the database once the task is started. This can be used to show an "approve" control in the UI.
waitAction := wf.ActionN(wd, "Wait for Approval", ApproveActionDep(db), wf.After(someDependency))
func ConnectMaintenanceDB ¶
func ConnectMaintenanceDB(ctx context.Context, cfg *pgx.ConnConfig, maintDB string) (*pgx.Conn, error)
ConnectMaintenanceDB connects to the maintenance database using the credentials from cfg. If maintDB is an empty string, the database with the name cfg.User will be used.
func CreateDBIfNotExists ¶
CreateDBIfNotExists checks whether the given dbName is an existing database, and creates one if not.
func DropDB ¶
DropDB drops the database specified in cfg. An error returned if the database does not exist.
func InitDB ¶
InitDB creates and applies all migrations to the database specified in conn.
If the database does not exist, one will be created using the credentials provided.
Any key/value or URI string compatible with libpq is valid.
func LogOnlyMailer ¶
func LogOnlyMailer(header task.MailHeader, content task.MailContent) error
func MigrateDB ¶
MigrateDB applies all migrations to the database specified in conn.
Any key/value or URI string compatible with libpq is a valid conn. If downUp is true, all migrations will be run, then the down and up migrations of the final migration are run.
func RegisterReleaseWorkflows ¶
func RegisterReleaseWorkflows(ctx context.Context, h *DefinitionHolder, build *BuildReleaseTasks, milestone *task.MilestoneTasks, version *task.VersionTasks, comm task.CommunicationTasks) error
RegisterReleaseWorkflows registers workflows for issuing Go releases.
func UnmarshalWorkflow ¶
Types ¶
type BuildReleaseTasks ¶
type BuildReleaseTasks struct { GerritClient task.GerritClient GerritProject string GerritHTTPClient *http.Client // GerritHTTPClient is an HTTP client that authenticates to Gerrit instances. (Both public and private.) PrivateGerritClient task.GerritClient PrivateGerritProject string GCSClient *storage.Client ScratchFS *task.ScratchFS SignedURL string // SignedURL is a gs:// or file:// URL, no trailing slash. ServingURL string // ServingURL is a gs:// or file:// URL, no trailing slash. DownloadURL string ProxyPrefix string // ProxyPrefix is the prefix at which module files are published, e.g. https://proxy.golang.org/golang.org/toolchain/@v PublishFile func(task.WebsiteFile) error SignService sign.Service GoogleDockerBuildProject string GoogleDockerBuildTrigger string CloudBuildClient task.CloudBuildClient BuildBucketClient task.BuildBucketClient SwarmingClient task.SwarmingClient ApproveAction func(*wf.TaskContext) error }
BuildReleaseTasks serves as an adapter to the various build tasks in the task package.
type DefinitionHolder ¶
type DefinitionHolder struct {
// contains filtered or unexported fields
}
DefinitionHolder holds workflow definitions.
func NewDefinitionHolder ¶
func NewDefinitionHolder() *DefinitionHolder
NewDefinitionHolder creates a new DefinitionHolder, initialized with a sample "echo" wf.
func (*DefinitionHolder) Definition ¶
func (h *DefinitionHolder) Definition(name string) *wf.Definition
Definition returns the initialized wf.Definition registered for a given name.
func (*DefinitionHolder) Definitions ¶
func (h *DefinitionHolder) Definitions() map[string]*wf.Definition
Definitions returns the names of all registered definitions.
func (*DefinitionHolder) RegisterDefinition ¶
func (h *DefinitionHolder) RegisterDefinition(name string, d *wf.Definition)
RegisterDefinition registers a definition with a name. If a definition with the same name already exists, RegisterDefinition panics.
type FailedToScheduleEntry ¶
type FailedToScheduleEntry struct { WorkflowSchedule ParsedSchedule cron.Schedule LastRun db.SchedulesLastRunRow }
func (FailedToScheduleEntry) Next ¶
func (e FailedToScheduleEntry) Next() time.Time
type PGListener ¶
type PGListener struct { DB db.PGDBTX BaseURL *url.URL ScheduleFailureMailHeader task.MailHeader SendMail func(task.MailHeader, task.MailContent) error // contains filtered or unexported fields }
PGListener implements workflow.Listener for recording workflow state.
func (*PGListener) TaskStateChanged ¶
func (l *PGListener) TaskStateChanged(workflowID uuid.UUID, taskName string, state *workflow.TaskState) error
TaskStateChanged is called whenever a task is updated by the workflow. The workflow.TaskState is persisted as a db.Task, creating or updating a row as necessary.
func (*PGListener) WorkflowFinished ¶
func (l *PGListener) WorkflowFinished(ctx context.Context, workflowID uuid.UUID, outputs map[string]interface{}, workflowErr error) error
WorkflowFinished saves the final state of a workflow after its run has completed.
func (*PGListener) WorkflowStalled ¶
func (l *PGListener) WorkflowStalled(workflowID uuid.UUID) error
WorkflowStalled is called when no tasks are runnable.
type RunOnce ¶
type RunOnce struct {
// contains filtered or unexported fields
}
RunOnce is a cron.Schedule for running a job at a specific time.
type Schedule ¶
type Schedule struct { Once time.Time Cron string Type ScheduleType }
Schedule represents the interval on which a job should be run. Only Type and one other field should be set.
type ScheduleEntry ¶
type ScheduleEntry struct { // Entry is the cron entry. // // Its Job field holds a *WorkflowSchedule that describes the scheduled // workflow and how to start running a new instance of it. cron.Entry LastRun db.SchedulesLastRunRow }
func (*ScheduleEntry) WorkflowJob ¶
func (s *ScheduleEntry) WorkflowJob() *WorkflowSchedule
WorkflowJob returns a *WorkflowSchedule for the ScheduleEntry.
type ScheduleType ¶
type ScheduleType string
ScheduleType determines whether a workflow runs immediately or on some future date or cadence.
const ( ScheduleImmediate ScheduleType = "Immediate" ScheduleOnce ScheduleType = "Future Date" ScheduleCron ScheduleType = "Cron" )
func (ScheduleType) ElementID ¶
func (s ScheduleType) ElementID() string
ElementID returns a string suitable for a HTML element ID.
func (ScheduleType) FormField ¶
func (s ScheduleType) FormField() string
FormField returns a string representing which datatype to present the user on the creation form.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func NewScheduler ¶
NewScheduler returns a Scheduler ready to run jobs.
func (*Scheduler) Create ¶
func (s *Scheduler) Create(ctx context.Context, sched Schedule, workflowName string, params map[string]any) (row db.Schedule, err error)
Create schedules a job and records it in the database.
func (*Scheduler) Delete ¶
Delete removes a schedule from the scheduler, preventing subsequent runs, and deletes the schedule from the database.
Jobs in progress are not interrupted, but will be prevented from starting again.
func (*Scheduler) Entries ¶
func (s *Scheduler) Entries(ctx context.Context, workflowNames ...string) ([]ScheduleEntry, []FailedToScheduleEntry)
Entries returns a list of scheduled jobs, and a list of jobs that failed to schedule.
The scheduled jobs are filtered by workflowNames, if provided, otherwise all scheduled jobs are included.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements the http handlers for relui.
func NewServer ¶
func NewServer(p db.PGDBTX, w *Worker, baseURL *url.URL, header SiteHeader, ms *metrics.Service, cria *criadb.AuthDatabase) *Server
NewServer initializes a server with the provided connection pool, worker, base URL and site header.
The base URL may be nil, which is the same as "/".
cria may be nil, in which case workflows are unrestricted, this is mainly intended to ease development.
type SiteHeader ¶
type SiteHeader struct { Title string // Site title. For example, "Go Releases". CSSClass string // Site header CSS class name. Optional. Subtitle string NameParam string }
SiteHeader configures the relui site header.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker runs workflows, and persists their state.
func NewWorker ¶
func NewWorker(dh *DefinitionHolder, db db.PGDBTX, l Listener) *Worker
NewWorker returns a Worker ready to accept and run workflows.
type WorkflowSchedule ¶
type WorkflowSchedule struct { Schedule db.Schedule Params map[string]any // contains filtered or unexported fields }
WorkflowSchedule represents the data needed to create a Workflow.
func (WorkflowSchedule) ParamDesc ¶
func (w WorkflowSchedule) ParamDesc() string
ParamDesc returns a description of the parameters.
func (WorkflowSchedule) ScheduleDesc ¶
func (w WorkflowSchedule) ScheduleDesc() string
ScheduleDesc returns a description of the schedule.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package groups contains group definitions for ACL purposes.
|
Package groups contains group definitions for ACL purposes. |
Package sign provides implementations for servers which can sign Go release artifacts.
|
Package sign provides implementations for servers which can sign Go release artifacts. |