Documentation ¶
Index ¶
- Constants
- func ConvertIso8601ToCron(isoRep string) (string, error)
- func ImmediateCrontab() string
- func RunOnceNowSchedule() string
- func TwentyFourHoursAgo() int64
- type ActiveRun
- type Artifact
- type Client
- func (client *Client) CreateJob(job *Job) (*Job, error)
- func (client *Client) CreateSchedule(jobID string, sched *Schedule) (interface{}, error)
- func (client *Client) DeleteJob(jobID string) (interface{}, error)
- func (client *Client) DeleteSchedule(jobID string, schedID string) (interface{}, error)
- func (client *Client) GetJob(jobID string) (*Job, error)
- func (client *Client) GetSchedule(jobID string, schedID string) (*Schedule, error)
- func (client *Client) Jobs() (*[]Job, error)
- func (client *Client) Metrics() (interface{}, error)
- func (client *Client) Ping() (*string, error)
- func (client *Client) RunLs(jobID string) (*[]JobStatus, error)
- func (client *Client) Runs(jobID string, since int64) (*Job, error)
- func (client *Client) Schedules(jobID string) (*[]Schedule, error)
- func (client *Client) StartJob(jobID string) (interface{}, error)
- func (client *Client) StatusJob(jobID string, runID string) (*JobStatus, error)
- func (client *Client) StopJob(jobID string, runID string) (interface{}, error)
- func (client *Client) UpdateJob(jobID string, job *Job) (interface{}, error)
- func (client *Client) UpdateSchedule(jobID string, schedID string, sched *Schedule) (interface{}, error)
- type Config
- type Constraint
- type Container
- type ContainerPath
- type Docker
- type History
- type HistoryStatus
- type HistorySummary
- type Job
- func (theJob *Job) GetDescription() string
- func (theJob *Job) GetID() string
- func (theJob *Job) GetLabels() *Labels
- func (theJob *Job) GetRun() *Run
- func (theJob *Job) SetDescription(desc string) *Job
- func (theJob *Job) SetID(id string) *Job
- func (theJob *Job) SetLabel(label Labels) *Job
- func (theJob *Job) SetRun(run *Run) *Job
- type JobStatus
- type Jobs
- type Labels
- type Metronome
- type MountMode
- type Operator
- type Placement
- type Restart
- type Run
- func (runner *Run) AddArg(item string)
- func (runner *Run) GetArgs() *[]string
- func (runner *Run) GetArtifacts() []Artifact
- func (runner *Run) GetCmd() string
- func (runner *Run) GetCpus() float64
- func (runner *Run) GetDisk() int
- func (runner *Run) GetDocker() *Docker
- func (runner *Run) GetEnv() map[string]string
- func (runner *Run) GetMaxLaunchDelay() int
- func (runner *Run) GetMem() int
- func (runner *Run) GetPlacement() *Placement
- func (runner *Run) GetRestart() *Restart
- func (runner *Run) GetUser() string
- func (runner *Run) GetVolumes() *[]Volume
- func (runner *Run) SetArgs(newargs []string) *Run
- func (runner *Run) SetArtifacts(artifacts []Artifact) *Run
- func (runner *Run) SetCmd(cmd string) *Run
- func (runner *Run) SetCpus(p float64) *Run
- func (runner *Run) SetDisk(p int) *Run
- func (runner *Run) SetDocker(docker *Docker) *Run
- func (runner *Run) SetEnv(mp map[string]string) *Run
- func (runner *Run) SetMaxLaunchDelay(p int) *Run
- func (runner *Run) SetMem(p int) *Run
- func (runner *Run) SetPlacement(p *Placement) *Run
- func (runner *Run) SetRestart(restart *Restart) *Run
- func (runner *Run) SetUser(user string) *Run
- func (runner *Run) SetVolumes(vols []Volume) *Run
- type Schedule
- type TaskStatus
- type Volume
Constants ¶
const ( HTTPGet = "GET" HTTPPut = "PUT" HTTPDelete = "DELETE" HTTPPost = "POST" )
Constants to represent HTTP verbs
const ( // POST /v1/jobs MetronomeAPIJobCreate = "/v1/jobs" // DELETE /v1/jobs/$jobId MetronomeAPIJobDelete = "/v1/jobs/%s" // GET /v1/jobs/$jobId MetronomeAPIJobGet = "/v1/jobs/%s" // GET /v1/jobs MetronomeAPIJobList = "/v1/jobs" // PUT /v1/jobs/$jobId MetronomeAPIJobUpdate = "/v1/jobs/%s" // GET /v1/jobs/$jobId/runs MetronomeAPIJobRunList = "/v1/jobs/%s/runs" // POST /v1/jobs/$jobId/runs MetronomeAPIJobRunStart = "/v1/jobs/%s/runs" // GET /v1/jobs/$jobId/runs/$runId MetronomeAPIJobRunStatus = "/v1/jobs/%s/runs/%s" // POST /v1/jobs/$jobId/runs/$runId/action/stop MetronomeAPIJobRunStop = "/v1/jobs/%s/runs/%s/actions/stop" // POST /v1/jobs/$jobId/schedules MetronomeAPIJobScheduleCreate = "/v1/jobs/%s/schedules" // GET /v1/jobs/$jobId/schedules/$scheduleId MetronomeAPIJobScheduleStatus = "/v1/jobs/%s/schedules/%s" // GET /v1/jobs/$jobId/schedules MetronomeAPIJobScheduleList = "/v1/jobs/%s/schedules" // DELETE /v1/jobs/$jobId/schedules/$scheduleId MetronomeAPIJobScheduleDelete = "/v1/jobs/%s/schedules/%s" // PUT /v1/jobs/$jobId/schedules/$scheduleId MetronomeAPIJobScheduleUpdate = "/v1/jobs/%s/schedules/%s" // GET /v1/metrics MetronomeAPIMetrics = "/v1/metrics" // GET /v1/ping MetronomeAPIPing = "/ping" )
Constants defining the various metronome endpoints
Variables ¶
This section is empty.
Functions ¶
func ConvertIso8601ToCron ¶
ConvertIso8601ToCron - attempts to convert an iso8601, 3 -part date into a cron repre. Experimental
- only simple cases will work without creating *multiple* schedules
func ImmediateCrontab ¶
func ImmediateCrontab() string
ImmediateCrontab - generates a point in time crontab
func RunOnceNowSchedule ¶
func RunOnceNowSchedule() string
RunOnceNowSchedule will return a schedule that starts immediately, runs once, and runs every 2 minutes until successful
func TwentyFourHoursAgo ¶
func TwentyFourHoursAgo() int64
TwentyFourHoursAgo - return time 24 hours ago
Types ¶
type ActiveRun ¶
type ActiveRun struct { ID string `json:"id"` JobID string `json:"jobId"` Status string `json:"status"` CreatedAt string `json:"createdAt"` CompletedAt interface{} `json:"completedAt"` Tasks []TaskStatus `json:"tasks"` }
ActiveRun - undocumented structure returned via api for job runs
type Artifact ¶
type Artifact struct { URI string `json:"uri"` Executable bool `json:"executable"` Extract bool `json:"extract"` Cache bool `json:"cache"` }
Artifact - Metronome Artifact
func (*Artifact) IsExecutable ¶
IsExecutable - is the artifact executable
func (*Artifact) ShouldCache ¶
ShouldCache - should the artifact be cached
func (*Artifact) ShouldExtract ¶
ShouldExtract - does the artifact need to be extracted
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client can make http requests
func (*Client) CreateSchedule ¶
CreateSchedule - assign a schedule to a job POST /v1/jobs/$jobId/schedules
func (*Client) DeleteJob ¶
DeleteJob - deletes a job by calling metronome api DELETE /v1/jobs/$jobId
func (*Client) DeleteSchedule ¶
DeleteSchedule - delete a schedule DELETE /v1/jobs/$jobId/schedules/$scheduleId
func (*Client) GetSchedule ¶
GetSchedule - get a schedule associated with a job GET /v1/jobs/$jobId/schedules/$scheduleId
func (*Client) Ping ¶
Ping - test if the metronome service is running. returns 'pong' on success
GET /v1/ping
func (*Client) StartJob ¶
StartJob - starts a metronome job. Implies that CreateJob was already called. POST /v1/jobs/$jobId/runs
func (*Client) StopJob ¶
StopJob - stop a running job. returns and error on failure POST /v1/jobs/$jobId/runs/$runId/action/stop
type Config ¶
type Config struct { /* the url for metronome */ URL string /* switch on debugging */ Debug bool /* the timeout for requests */ RequestTimeout int /* allow unverified tls (self-signed certs) defaults to false */ AllowUnverifiedTLS bool AuthToken string User string Pw string }
A Config defines a client configuration
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig returns a default configuration. Helpful for local testing/development.
type Constraint ¶
type Constraint struct { Attribute string `json:"attribute"` // operator is EQ, LIKE,UNLIKE Operator Operator `json:"operator"` Value string `json:"value"` }
Constraint - Metronome constraint
func NewConstraint ¶
func NewConstraint(attribute string, op Operator, value string) (*Constraint, error)
NewConstraint - create Metronome constraint
func StrToConstraint ¶
func StrToConstraint(cli string) (*Constraint, error)
StrToConstraint - takes constraint as described in Metronome documentation
func (*Constraint) GetAttribute ¶
func (theConstraint *Constraint) GetAttribute() string
GetAttribute - accessor
func (*Constraint) GetOperator ¶
func (theConstraint *Constraint) GetOperator() Operator
GetOperator - accessor
func (*Constraint) GetValue ¶
func (theConstraint *Constraint) GetValue() string
GetValue - accessor
type Container ¶
type Container struct { Type string `json:"type,omitempty"` Image string `json:"image,omitempty"` Network string `json:"network,omitempty"` Volumes []map[string]string `json:"volumes,omitempty"` }
A Container defines a metronome container
type ContainerPath ¶
type ContainerPath string
ContainerPath - type for contraining json values to limited paths spec'd in metronome api
func NewContainerPath ¶
func NewContainerPath(path string) (self ContainerPath, err error)
NewContainerPath - create a new container path that's checked for validity per Metronome's doc
func (*ContainerPath) MarshalJSON ¶
func (cp *ContainerPath) MarshalJSON() ([]byte, error)
MarshalJSON - json interface implementation
func (*ContainerPath) UnmarshalJSON ¶
func (cp *ContainerPath) UnmarshalJSON(raw []byte) error
UnmarshalJSON - json interface implementation. ensure valid path as spec'd by metronome api
type Docker ¶
type Docker struct {
Image string `json:"image"`
}
Docker - metronome limited docker image
func NewDockerImage ¶
NewDockerImage - create a new image
type History ¶
type History struct { SuccessCount int `json:"successCount"` FailureCount int `json:"failureCount"` LastSuccessAt string `json:"lastSuccessAt"` LastFailureAt string `json:"lastFailureAt"` SuccessfulFinishedRuns []HistoryStatus `json:"successfulFinishedRuns"` FailedFinishedRuns []HistoryStatus `json:"failedFinishedRuns"` }
History - undocumented structure returned by Metronome api for job runs
type HistoryStatus ¶
type HistoryStatus struct { ID string `json:"id"` CreatedAt string `json:"createdAt"` FinishedAt string `json:"finishedAt"` }
HistoryStatus - history outcome of previous jobs
type HistorySummary ¶
type HistorySummary struct { SuccessCount int `json:"successCount"` FailureCount int `json:"failureCount"` LastSuccessAt string `json:"lastSuccessAt"` LastFailureAt string `json:"lastFailureAt"` }
HistorySummary - undocumented structure returned by Metronome api for job runs
type Job ¶
type Job struct { Description string `json:"description"` ID string `json:"id"` Labels *Labels `json:"labels,omitempty"` Run *Run `json:"run"` Schedules []*Schedule `json:"schedules,omitempty"` ActiveRuns []*ActiveRun `json:"activeRuns,omitempty"` History *History `json:"history,omitempty"` HistorySummary *HistorySummary `json:"historySummary,omitempty"` }
Job - toplevel metronome structure for creating and managing a job
func (*Job) GetDescription ¶
GetDescription - get the job description
func (*Job) SetDescription ¶
SetDescription - set the job description.
type JobStatus ¶
type JobStatus struct { CompletedAt interface{} `json:"completedAt"` CreatedAt string `json:"createdAt"` ID string `json:"id"` JobID string `json:"jobId"` Status string `json:"status"` Tasks []TaskStatus `json:"tasks"` }
JobStatus - represents a metronome job status
type Metronome ¶
type Metronome interface { // POST /v1/jobs CreateJob(*Job) (*Job, error) // DELETE /v1/jobs/$jobId DeleteJob(jobID string) (interface{}, error) // GET /v1/jobs/$jobId GetJob(jobID string) (*Job, error) // GET /v1/jobs Jobs() (*[]Job, error) // PUT /v1/jobs/$jobId UpdateJob(jobID string, job *Job) (interface{}, error) Runs(jobID string, statusSince int64) (*Job, error) // POST /v1/jobs/$jobId/runs StartJob(jobID string) (interface{}, error) // GET /v1/jobs/$jobId/runs/$runId StatusJob(jobID string, runID string) (*JobStatus, error) // POST /v1/jobs/$jobId/runs/$runId/action/stop StopJob(jobID string, runID string) (interface{}, error) // // Schedules // // POST /v1/jobs/$jobId/schedules CreateSchedule(jobID string, new *Schedule) (interface{}, error) // GET /v1/jobs/$jobId/schedules/$scheduleId GetSchedule(jobID string, schedID string) (*Schedule, error) // GET /v1/jobs/$jobId/schedules Schedules(jobID string) (*[]Schedule, error) // DELETE /v1/jobs/$jobId/schedules/$scheduleId DeleteSchedule(jobID string, schedID string) (interface{}, error) // PUT /v1/jobs/$jobId/schedules/$scheduleId UpdateSchedule(jobID string, schedID string, sched *Schedule) (interface{}, error) // GET /v1/metrics Metrics() (interface{}, error) // GET /v1/ping Ping() (*string, error) }
Metronome represents the client interface for interacting with the metronome API
type MountMode ¶
type MountMode int
MountMode - type for constraining json values to those spec'd in metronome api
func (*MountMode) MarshalJSON ¶
MarshalJSON - json interface requirement
func (*MountMode) UnmarshalJSON ¶
UnmarshalJSON - json interface implementation. Ensure we have a valid mount value
type Operator ¶
type Operator int
Operator - constrain operator values
func (*Operator) MarshalJSON ¶
MarshalJSON - implement json interface for marshalling json
func (*Operator) UnmarshalJSON ¶
UnmarshalJSON - hand json unmarshalling
type Placement ¶
type Placement struct {
Constraints []Constraint `json:"constraints"`
}
Placement - Metronome placement
func (*Placement) GetConstraints ¶
func (thePlacement *Placement) GetConstraints() ([]Constraint, error)
GetConstraints - return constraints
type Restart ¶
type Restart struct { ActiveDeadlineSeconds int `json:"activeDeadlineSeconds"` Policy string `json:"policy"` }
Restart - structure representing a Metronome structure
type Run ¶
type Run struct { Artifacts []Artifact `json:"artifacts,omitempty"` Cmd string `json:"cmd,omitempty"` Args []string `json:"args,omitempty"` Cpus float64 `json:"cpus"` Mem int `json:"mem"` Disk int `json:"disk"` Docker *Docker `json:"docker,omitempty"` Env map[string]string `json:"env,omitempty"` MaxLaunchDelay int `json:"maxLaunchDelay"` Placement *Placement `json:"placement,omitempty"` Restart *Restart `json:"restart,omitempty"` User string `json:"user,omitempty"` Volumes []Volume `json:"volumes"` }
Run - composite structure representing Metronone run
func (*Run) GetArtifacts ¶
GetArtifacts - accessor returning Artifacts
func (*Run) GetMaxLaunchDelay ¶
GetMaxLaunchDelay - accessor returning the maximum launch delay
func (*Run) GetPlacement ¶
GetPlacement - get the placement
func (*Run) GetRestart ¶
GetRestart - the restart structure
func (*Run) GetVolumes ¶
GetVolumes - get job's Volume mappings
func (*Run) SetArtifacts ¶
SetArtifacts - set Artifacts returning pointer to Run so they can be setters can be chained together
func (*Run) SetMaxLaunchDelay ¶
SetMaxLaunchDelay - set the delay
func (*Run) SetPlacement ¶
SetPlacement - set the job placement
func (*Run) SetRestart ¶
SetRestart - set the restart structure
func (*Run) SetVolumes ¶
SetVolumes - set the job's Volume mappings
type Schedule ¶
type Schedule struct { ID string `json:"id"` Cron string `json:"cron"` ConcurrencyPolicy string `json:"concurrencyPolicy"` Enabled bool `json:"enabled"` StartingDeadlineSeconds int `json:"startingDeadlineSeconds"` Timezone string `json:"timezone"` NextRunAt string `json:"nextRunAt,omitempty"` }
Schedule - represent a metronome schedule
func ImmediateSchedule ¶
ImmediateSchedule - create a metronome schedule
type TaskStatus ¶
type TaskStatus struct { ID string `json:"id"` StartedAt string `json:"startedAt"` Status string `json:"status"` }
TaskStatus - status of currently running task representing job
type Volume ¶
type Volume struct { // minlength 1; pattern: ^/[^/].*$ ContainerPath ContainerPath `json:"containerPath"` HostPath string `json:"hostPath"` // Values: RW,RO Mode MountMode `json:"mode"` }
Volume - structure representing a Metronome Volume validated types