Documentation
¶
Overview ¶
Longer running tasks.
The job system allows go routines running custom logic, called jobs, to be started. See JobRunner for usage instructions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job interface { // Do job. Data argument holds arbitrary data. It is up to each job // to define what data it takes. Do(data []byte) error }
Job is a piece of logic
type JobRunner ¶
type JobRunner struct { // Ctx Ctx context.Context // Logger Logger golog.Logger // Cfg is the server configuration Cfg *config.Config // Metrics holds internal Prometheus metrics recorders Metrics metrics.Metrics // GH is a GitHub API client GH *github.Client // MDbApps is used to access the apps collection MDbApps *mongo.Collection // contains filtered or unexported fields }
JobRunner manages starting jobs and shutting down gracefully
func (*JobRunner) Init ¶
func (r *JobRunner) Init()
Init initializes a JobRunner. The Submit() and Run() methods will not work properly unless this method is called.
type JobStartRequest ¶
type JobStartRequest struct { // Type of job to start Type JobTypeT // Data required to start job Data []byte // CompleteChan will close when the job has been completed. This // does not guarantee the job finished successfully CompleteChan chan interface{} }
JobStartRequest provides informtion required to start a job
type JobTypeT ¶
type JobTypeT string
JobTypeT is used to specify what type of job to start
const ( JobTypeUpdateApps JobTypeT = "update_apps" JobTypeValidate = "validate" )
Job types identify different jobs which can be run
type UpdateAppsJob ¶
type UpdateAppsJob struct { // Ctx Ctx context.Context // Cfg is the server configuration Cfg *config.Config // GH is a GitHub API client GH *github.Client // MDbApps is used to access the apps collection MDbApps *mongo.Collection }
UpdateAppsJob updates the apps collection based on the current master branch state The data field is optional. If provided must be a JSON encoded UpdateAppsJobDefinition.
type UpdateAppsJobDefinition ¶
type UpdateAppsJobDefinition struct { // NoBotAPINotify when true indicates that the job should not make a request // to the bot API new apps endpoint NoBotAPINotify bool }
UpdateAppsJobDefinition specifies the behavior of an UpdateAppsJob
type ValidateJob ¶
type ValidateJob struct { // Ctx Ctx context.Context // Logger Logger golog.Logger // Cfg is the server configuration Cfg *config.Config // GH is a GitHub API client GH *github.Client }
ValidateJob updates the apps collection based on the current master branch state Expects the data passed to Do() to be a github.PullRequest in JSON form. This pull request will be validated.