client

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2015 License: MIT Imports: 9 Imported by: 0

README

chronos-client

Build Status GoDoc Release

A Go Chronos client library that provides Chronos operations.

Installation

go get github.com/yieldbot/chronos-client

Usage

Getting jobs

See jobs.go for full code.

jobs, err := chronos.Client.Jobs()
if err != nil {
  log.Fatal(err)
}
for _, j := range jobs {
  fmt.Printf("%s\n", j.Name)
}
Adding a job

See add.go for full code.

var j = `{"schedule": "R/2015-11-09T00:00:00Z/PT24H", "name": "test-1", "epsilon": "PT30M", "command": "echo test1 && sleep 60", "owner": "localhost@localhsot", "async": false}`
_, err := chronos.Client.AddJob(j)
if err != nil {
  log.Fatal(err)
}
fmt.Printf("The job is added\n")
Running a job

See run.go for full code.

_, err := chronos.Client.RunJob("test-1", "")
if err != nil {
  log.Fatal(err)
}
fmt.Printf("test-1 job is running\n")
Killing job tasks

See killtasks.go for full code.

_, err := chronos.Client.KillJobTasks("test-1")
if err != nil {
  log.Fatal(err)
}
fmt.Printf("test-1 job tasks are killed\n")
Deleting a job

See delete.go for full code.

_, err := chronos.Client.DeleteJob("test-1")
if err != nil {
  log.Fatal(err)
}
fmt.Printf("test-1 job is deleted\n")

License

Licensed under The MIT License (MIT)
For the full copyright and license information, please view the LICENSE.txt file.

[coverage-image]: https://coveralls.io/repos/yieldbot/chronos-client/badge.svg?branch=master&service=github)

Documentation

Overview

Package client provides Chronos operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	URL      string
	ProxyURL *url.URL
}

Client represents the Chronos client interface

func (Client) AddDepJob

func (cl Client) AddDepJob(jsonContent string) (bool, error)

AddDepJob adds a Chronos dependent job

func (Client) AddJob

func (cl Client) AddJob(jsonContent string) (bool, error)

AddJob adds a Chronos job

func (Client) DeleteJob

func (cl Client) DeleteJob(jobName string) (bool, error)

DeleteJob deletes a Chronos job

func (Client) DepGraph

func (cl Client) DepGraph() (string, error)

DepGraph returns the Chronos dependency Graph in the dotfile format

func (Client) Jobs

func (cl Client) Jobs() ([]Job, error)

Jobs returns the Chronos jobs

func (Client) KillJobTasks

func (cl Client) KillJobTasks(jobName string) (bool, error)

KillJobTasks kills the Chronos job tasks

func (Client) PrintJobs

func (cl Client) PrintJobs(pretty bool) error

PrintJobs prints the Chronos jobs

func (Client) RunJob

func (cl Client) RunJob(jobName, args string) (bool, error)

RunJob runs a Chronos job

func (Client) UpdateJobTaskProgress

func (cl Client) UpdateJobTaskProgress(jobName, taskID, jsonContent string) (bool, error)

UpdateJobTaskProgress updates a Chronos job task progress

type EnvVars

type EnvVars struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

EnvVars represents Chronos job environmentVariables field

type Job

type Job struct {
	Name                 string        `json:"name"`
	Description          string        `json:"description"`
	Command              string        `json:"command"`
	Arguments            []string      `json:"arguments"`
	Shell                bool          `json:"shell"`
	Epsilon              string        `json:"epsilon"`
	Executor             string        `json:"executor"`
	ExecutorFlags        string        `json:"executorFlags"`
	Retries              int           `json:"retries"`
	Owner                string        `json:"owner"`
	OwnerName            string        `json:"ownerName"`
	Async                bool          `json:"async"`
	SuccessCount         int           `json:"successCount"`
	ErrorCount           int           `json:"errorCount"`
	LastSuccess          string        `json:"lastSuccess"`
	LastError            string        `json:"lastError"`
	Cpus                 float64       `json:"cpus"`
	Mem                  float64       `json:"mem"`
	Disk                 float64       `json:"disk"`
	Disabled             bool          `json:"disabled"`
	Uris                 []string      `json:"uris"`
	Schedule             string        `json:"schedule"`
	ScheduleTimeZone     string        `json:"scheduleTimeZone"`
	Parents              []string      `json:"parents"`
	RunAsUser            string        `json:"runAsUser"`
	Container            *JobContainer `json:"container"`
	DataJob              bool          `json:"dataJob"`
	EnvironmentVariables []*EnvVars    `json:"environmentVariables"`
	Constraints          [][]string    `json:"constraints"`
}

Job represents Chronos job configuration

type JobContainer

type JobContainer struct {
	Type           string        `json:"type"`
	Image          string        `json:"image"`
	ForcePullImage bool          `json:"forcePullImage"`
	Network        string        `json:"network"`
	Volumes        []interface{} `json:"arguments"`
}

JobContainer represents Chronos job container field

Directories

Path Synopsis
examples
add command
delete command
jobs command
killtasks command
print command
run command

Jump to

Keyboard shortcuts

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