metronome

package
v0.0.0-...-11f2a26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a client for Cosmos.

func NewClient

func NewClient(baseClient *httpclient.Client, logger *logrus.Logger) *Client

NewClient creates a new Metronome client.

func (*Client) AddJob

func (c *Client) AddJob(job *Job) (*Job, error)

AddJob creates a job.

func (*Client) AddSchedule

func (c *Client) AddSchedule(jobID string, schedule *Schedule) (*Schedule, error)

AddSchedule adds a schedule to the job with the given jobID.

func (*Client) Job

func (c *Client) Job(jobID string, opts ...JobsOption) (*Job, error)

Job returns a Job for the given jobID.

func (*Client) Jobs

func (c *Client) Jobs(opts ...JobsOption) ([]Job, error)

Jobs returns a list of all job definitions.

func (*Client) Kill

func (c *Client) Kill(jobID, runID string) error

Kill stops a run of a given jobID and runID.

func (*Client) Queued

func (c *Client) Queued(jobID string) ([]Queue, error)

Queued returns all queued runs for the existing jobs.

func (*Client) RemoveJob

func (c *Client) RemoveJob(jobID string, force bool) error

RemoveJob removes a job.

func (*Client) RemoveSchedule

func (c *Client) RemoveSchedule(jobID, scheduleID string) error

RemoveSchedule removes a schedule from a job with the given jobID and scheduleID.

func (*Client) Run

func (c *Client) Run(jobID, runID string) (*Run, error)

Run returns the run object for a given jobID and runID.

func (*Client) RunJob

func (c *Client) RunJob(jobID string) (*Run, error)

RunJob triggers a run of the job with a given jobID right now.

func (*Client) Runs

func (c *Client) Runs(jobID string) ([]Run, error)

Runs returns the run objects for a given jobID.

func (*Client) Schedules

func (c *Client) Schedules(jobID string) ([]Schedule, error)

Schedules returns the schedules for a given jobID.

func (*Client) UpdateJob

func (c *Client) UpdateJob(job *Job) (*Job, error)

UpdateJob updates an existing job.

func (*Client) UpdateSchedule

func (c *Client) UpdateSchedule(jobID string, schedule *Schedule) (*Schedule, error)

UpdateSchedule updates a schedule of a job with the given jobID.

type Error

type Error struct {
	Code    int      `json:"code"`
	Message string   `json:"message"`
	Details []detail `json:"details"`
}

Error is a standard error returned by the DC/OS API.

func (*Error) Error

func (err *Error) Error() string

Error converts an API error to a string.

type Job

type Job struct {
	ID           string            `json:"id"`
	Dependencies []dependency      `json:"dependencies,omitempty"`
	Description  string            `json:"description"`
	Labels       map[string]string `json:"labels,omitempty"`
	// The run property of a Job represents the run configuration for that Job
	Run struct {
		Args                       []string               `json:"args,omitempty"`
		Artifacts                  []artifact             `json:"artifacts,omitempty"`
		Cmd                        string                 `json:"cmd"`
		Cpus                       float32                `json:"cpus"`
		Gpus                       float32                `json:"gpus"`
		Disk                       int                    `json:"disk"`
		Docker                     *docker                `json:"docker,omitempty"`
		Env                        map[string]interface{} `json:"env,omitempty"`
		MaxLaunchDelay             int                    `json:"maxLaunchDelay,omitempty"`
		Mem                        int                    `json:"mem"`
		Placement                  *placement             `json:"placement,omitempty"`
		Secrets                    map[string]interface{} `json:"secrets,omitempty"`
		TaskKillGracePeriodSeconds float64                `json:"taskKillGracePeriodSeconds"`
		UCR                        *ucr                   `json:"ucr,omitempty"`
		User                       string                 `json:"user,omitempty"`
		Restart                    *restart               `json:"restart,omitempty"`
		Volumes                    []volume               `json:"volumes,omitempty"`
	} `json:"run"`

	// These properties depend on the embed parameters when querying the /v1/jobs endpoints.
	ActiveRuns     []Run              `json:"activeRuns,omitempty"`
	HistorySummary *JobHistorySummary `json:"historySummary,omitempty"`
	History        *JobHistory        `json:"history,omitempty"`
	Schedules      []Schedule         `json:"schedules,omitempty"`
}

Job represents a Job returned by the Metronome API.

func (*Job) LastRunStatus

func (j *Job) LastRunStatus() string

LastRunStatus returns the status of the last run of this job.

func (*Job) Status

func (j *Job) Status() string

Status returns the status of the job depending on its active runs and its schedule.

type JobHistory

type JobHistory struct {
	SuccessCount           int          `json:"successCount"`
	FailureCount           int          `json:"failureCount"`
	LastSuccessAt          string       `json:"lastSuccessAt"`
	LastFailureAt          string       `json:"lastFailureAt"`
	SuccessfulFinishedRuns []runHistory `json:"successfulFinishedRuns"`
	FailedRuns             []runHistory `json:"failedFinishedRuns"`
}

JobHistory contains statistics and information about past runs of a Job.

type JobHistorySummary

type JobHistorySummary struct {
	SuccessCount  int    `json:"successCount"`
	FailureCount  int    `json:"failureCount"`
	LastSuccessAt string `json:"lastSuccessAt"`
	LastFailureAt string `json:"lastFailureAt"`
}

JobHistorySummary contains statistics about past runs of a Job.

type JobsOption

type JobsOption func(query url.Values)

JobsOption is a functional Option to set the `embed` query parameters.

func EmbedActiveRun

func EmbedActiveRun() JobsOption

EmbedActiveRun sets the `embed` option to activeRuns.

func EmbedHistory

func EmbedHistory() JobsOption

EmbedHistory sets the `embed` option to history.

func EmbedHistorySummary

func EmbedHistorySummary() JobsOption

EmbedHistorySummary sets the `embed` option to historySummary.

func EmbedSchedule

func EmbedSchedule() JobsOption

EmbedSchedule sets the `embed` option to schedules.

type Queue

type Queue struct {
	JobID string      `json:"jobId"`
	Runs  []queuedRun `json:"runs"`
}

Queue contains all queued runs of a Job.

type Run

type Run struct {
	ID          string       `json:"id"`
	JobID       string       `json:"jobId"`
	Status      string       `json:"status"`
	CreatedAt   string       `json:"createdAt"`
	CompletedAt string       `json:"completedAt"`
	Tasks       []activeTask `json:"tasks"`
}

Run contains information about a run of a Job.

type Schedule

type Schedule struct {
	ID                      string `json:"id"`
	Cron                    string `json:"cron"`
	TimeZone                string `json:"timeZone,omitempty"`
	StartingDeadlineSeconds int    `json:"startingDeadlineSeconds,omitempty"`
	ConcurrencyPolicy       string `json:"concurrencyPolicy"`
	Enabled                 bool   `json:"enabled"`
	NextRunAt               string `json:"nextRunAt"`
}

Schedule of a Job.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL