luci: go.chromium.org/luci/scheduler/appengine/catalog Index | Files

package catalog

import "go.chromium.org/luci/scheduler/appengine/catalog"

Package catalog implements a part that talks to luci-config service to fetch and parse job definitions. Catalog knows about all task types and can instantiate task.Manager's.

Index

Package Files

catalog.go

type Catalog Uses

type Catalog interface {
    // RegisterTaskManager registers a manager that knows how to deal with
    // a particular kind of tasks (as specified by its ProtoMessageType method,
    // e.g. SwarmingTask proto).
    RegisterTaskManager(m task.Manager) error

    // GetTaskManager takes pointer to a proto message describing some task config
    // (e.g. SwarmingTask proto) and returns corresponding TaskManager
    // implementation (or nil).
    GetTaskManager(m proto.Message) task.Manager

    // UnmarshalTask takes a serialized task definition (as in Definition.Task),
    // unmarshals and validates it, and returns proto.Message that represent
    // the concrete task to run (e.g. SwarmingTask proto). It can be passed to
    // corresponding task.Manager.
    UnmarshalTask(c context.Context, task []byte) (proto.Message, error)

    // GetAllProjects returns a list of all known project ids.
    //
    // It assumes there's cfgclient implementation installed in
    // the context, will panic if it's not there.
    GetAllProjects(c context.Context) ([]string, error)

    // GetProjectJobs returns a list of scheduler jobs defined within a project or
    // empty list if no such project.
    //
    // It assumes there's cfgclient implementation installed in
    // the context, will panic if it's not there.
    GetProjectJobs(c context.Context, projectID string) ([]Definition, error)

    // RegisterConfigRules adds the config validation rules that verify job config
    // files.
    RegisterConfigRules(r *validation.RuleSet)
}

Catalog knows how to enumerate all scheduler configs across all projects. Methods return errors.Transient on non-fatal errors. Any other error means that retry won't help.

func New Uses

func New() Catalog

New returns implementation of Catalog.

type Definition Uses

type Definition struct {
    // JobID is globally unique job identifier: "<ProjectID>/<JobName>".
    JobID string

    // Acls describes who can read and who owns this job.
    Acls acl.GrantsByRole

    // Flavor describes what category of jobs this is, see the enum.
    Flavor JobFlavor

    // Revision is config revision this definition was fetched from.
    Revision string

    // RevisionURL is URL to human readable page with config file.
    RevisionURL string

    // Schedule is job's schedule in regular cron expression format.
    Schedule string

    // Task is serialized representation of scheduler job. It can be fed back to
    // Catalog.UnmarshalTask(...) to get proto.Message describing the task.
    //
    // Internally it is TaskDefWrapper proto message, but callers must treat it as
    // an opaque byte blob.
    Task []byte

    // TriggeringPolicy is serialized TriggeringPolicy proto that defines a
    // function that decides when to trigger invocations.
    //
    // It is taken verbatim from the config if defined there, or set to nil
    // if not there.
    TriggeringPolicy []byte

    // TriggeredJobIDs is a list of jobIDs which this job triggers.
    // It's set only for triggering jobs.
    TriggeredJobIDs []string
}

Definition wraps definition of a scheduler job fetched from the config.

type JobFlavor Uses

type JobFlavor int

JobFlavor describes a category of jobs.

const (
    // JobFlavorPeriodic is a regular job (Swarming, Buildbucket) that runs on
    // a schedule or via a trigger.
    //
    // Defined via 'job {...}' config stanza with 'schedule' field.
    JobFlavorPeriodic JobFlavor = iota

    // JobFlavorTriggered is a regular jog (Swarming, Buildbucket) that runs only
    // when triggered.
    //
    // Defined via 'job {...}' config stanza with no 'schedule' field.
    JobFlavorTriggered

    // JobFlavorTrigger is a job that can trigger other jobs (e.g. git poller).
    //
    // Defined via 'trigger {...}' config stanza.
    JobFlavorTrigger
)

Package catalog imports 21 packages (graph) and is imported by 10 packages. Updated 2018-10-21. Refresh now. Tools for package owners.