Add support for Async worker

This commit is contained in:
Seif Lotfy
2016-09-19 14:22:48 -07:00
parent b623fc27e4
commit 92df53b144
13 changed files with 285 additions and 342 deletions

View File

@@ -1,71 +0,0 @@
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)
/*Group group
swagger:model Group
*/
type Group struct {
/* Time when image first used/created.
Read Only: true
*/
CreatedAt strfmt.DateTime `json:"created_at,omitempty"`
/* User defined environment variables that will be passed in to each task in this group.
*/
EnvVars map[string]string `json:"env_vars,omitempty"`
/* Name of Docker image to use in this group. You should include the image tag, which should be a version number, to be more accurate. Can be overridden on a per task basis with task.image.
*/
Image string `json:"image,omitempty"`
/* The maximum number of tasks that will run at the exact same time in this group.
*/
MaxConcurrency int32 `json:"max_concurrency,omitempty"`
/* Name of this group. Must be different than the image name. Can ony contain alphanumeric, -, and _.
Read Only: true
*/
Name string `json:"name,omitempty"`
}
// Validate validates this group
func (m *Group) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateEnvVars(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Group) validateEnvVars(formats strfmt.Registry) error {
if swag.IsZero(m.EnvVars) { // not required
return nil
}
if err := validate.Required("env_vars", "body", m.EnvVars); err != nil {
return err
}
return nil
}

View File

@@ -1,50 +0,0 @@
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
)
/*GroupWrapper group wrapper
swagger:model GroupWrapper
*/
type GroupWrapper struct {
/* group
Required: true
*/
Group *Group `json:"group"`
}
// Validate validates this group wrapper
func (m *GroupWrapper) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateGroup(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *GroupWrapper) validateGroup(formats strfmt.Registry) error {
if m.Group != nil {
if err := m.Group.Validate(formats); err != nil {
return err
}
}
return nil
}

View File

@@ -1,48 +0,0 @@
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)
/*GroupsWrapper groups wrapper
swagger:model GroupsWrapper
*/
type GroupsWrapper struct {
/* groups
Required: true
*/
Groups []*Group `json:"groups"`
}
// Validate validates this groups wrapper
func (m *GroupsWrapper) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateGroups(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *GroupsWrapper) validateGroups(formats strfmt.Registry) error {
if err := validate.Required("groups", "body", m.Groups); err != nil {
return err
}
return nil
}

View File

@@ -1,95 +0,0 @@
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)
/*NewJob new job
swagger:model NewJob
*/
type NewJob struct {
/* Number of seconds to wait before queueing the job for consumption for the first time. Must be a positive integer. Jobs with a delay start in state "delayed" and transition to "running" after delay seconds.
*/
Delay int32 `json:"delay,omitempty"`
/* Name of Docker image to use. This is optional and can be used to override the image defined at the group level.
Required: true
*/
Image *string `json:"image"`
/* "Number of automatic retries this job is allowed. A retry will be attempted if a task fails. Max 25. Automatic retries are performed by titan when a task reaches a failed state and has `max_retries` > 0. A retry is performed by queueing a new job with the same image id and payload. The new job's max_retries is one less than the original. The new job's `retry_of` field is set to the original Job ID. Titan will delay the new job for retries_delay seconds before queueing it. Cancelled or successful tasks are never automatically retried."
*/
MaxRetries int32 `json:"max_retries,omitempty"`
/* Payload for the job. This is what you pass into each job to make it do something.
*/
Payload string `json:"payload,omitempty"`
/* Priority of the job. Higher has more priority. 3 levels from 0-2. Jobs at same priority are processed in FIFO order.
Required: true
*/
Priority *int32 `json:"priority"`
/* Time in seconds to wait before retrying the job. Must be a non-negative integer.
*/
RetriesDelay *int32 `json:"retries_delay,omitempty"`
/* Maximum runtime in seconds. If a consumer retrieves the
job, but does not change it's status within timeout seconds, the job
is considered failed, with reason timeout (Titan may allow a small
grace period). The consumer should also kill the job after timeout
seconds. If a consumer tries to change status after Titan has already
timed out the job, the consumer will be ignored.
*/
Timeout *int32 `json:"timeout,omitempty"`
}
// Validate validates this new job
func (m *NewJob) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateImage(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validatePriority(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *NewJob) validateImage(formats strfmt.Registry) error {
if err := validate.Required("image", "body", m.Image); err != nil {
return err
}
return nil
}
func (m *NewJob) validatePriority(formats strfmt.Registry) error {
if err := validate.Required("priority", "body", m.Priority); err != nil {
return err
}
return nil
}

View File

@@ -1,48 +0,0 @@
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)
/*NewJobsWrapper new jobs wrapper
swagger:model NewJobsWrapper
*/
type NewJobsWrapper struct {
/* jobs
Required: true
*/
Jobs []*NewJob `json:"jobs"`
}
// Validate validates this new jobs wrapper
func (m *NewJobsWrapper) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateJobs(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *NewJobsWrapper) validateJobs(formats strfmt.Registry) error {
if err := validate.Required("jobs", "body", m.Jobs); err != nil {
return err
}
return nil
}

View File

@@ -20,7 +20,7 @@ type NewTask struct {
*/
Delay int32 `json:"delay,omitempty"`
/* Name of Docker image to use. This is optional and can be used to override the image defined at the group level.
/* Name of Docker image to use. This is optional and can be used to override the image defined at the route level.
Required: true
*/

View File

@@ -31,7 +31,7 @@ type Task struct {
*/
CreatedAt strfmt.DateTime `json:"created_at,omitempty"`
/* Env vars for the task. Comes from the ones set on the Group.
/* Env vars for the task. Comes from the ones set on the Route.
*/
EnvVars map[string]string `json:"env_vars,omitempty"`
@@ -39,11 +39,11 @@ type Task struct {
*/
Error string `json:"error,omitempty"`
/* Group this task belongs to.
/* Route this task belongs to.
Read Only: true
*/
GroupName string `json:"group_name,omitempty"`
RouteName string `json:"route_name,omitempty"`
/* Machine usable reason for task being in this state.
Valid values for error status are `timeout | killed | bad_exit`.