worker

package module
v0.0.0-...-4726416 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

README

Go API client for worker

The ultimate, language agnostic, container based task processing framework.

Overview

This API client was generated by the swagger-codegen project. By using the swagger-spec from a remote server, you can easily generate an API client.

  • API version: 0.5.7
  • Package version: 0.5.7
  • Build date: 2016-08-24T18:32:22.010Z
  • Build package: class io.swagger.codegen.languages.GoClientCodegen

Installation

Put the package under your project folder and add the following in import:

    "./worker"

Documentation for API Endpoints

All URIs are relative to https://localhost:8080/v1

Class Method HTTP request Description
GroupsApi GroupsGet Get /groups Get all group names.
GroupsApi GroupsNameGet Get /groups/{name} Get information for a group.
GroupsApi GroupsNamePut Put /groups/{name} Create/update a task group.
GroupsApi GroupsPost Post /groups Post new group
RunnerApi GroupsNameTasksIdErrorPost Post /groups/{name}/tasks/{id}/error Mark task as failed.
RunnerApi GroupsNameTasksIdStartPost Post /groups/{name}/tasks/{id}/start Mark task as started, ie: status = 'running'
RunnerApi GroupsNameTasksIdSuccessPost Post /groups/{name}/tasks/{id}/success Mark task as succeeded.
TasksApi GroupsNameTasksGet Get /groups/{name}/tasks Get task list by group name.
TasksApi GroupsNameTasksIdCancelPost Post /groups/{name}/tasks/{id}/cancel Cancel a task.
TasksApi GroupsNameTasksIdDelete Delete /groups/{name}/tasks/{id} Delete the task.
TasksApi GroupsNameTasksIdErrorPost Post /groups/{name}/tasks/{id}/error Mark task as failed.
TasksApi GroupsNameTasksIdGet Get /groups/{name}/tasks/{id} Gets task by id
TasksApi GroupsNameTasksIdLogGet Get /groups/{name}/tasks/{id}/log Get the log of a completed task.
TasksApi GroupsNameTasksIdLogPost Post /groups/{name}/tasks/{id}/log Send in a log for storage.
TasksApi GroupsNameTasksIdRetryPost Post /groups/{name}/tasks/{id}/retry Retry a task.
TasksApi GroupsNameTasksIdStartPost Post /groups/{name}/tasks/{id}/start Mark task as started, ie: status = 'running'
TasksApi GroupsNameTasksIdSuccessPost Post /groups/{name}/tasks/{id}/success Mark task as succeeded.
TasksApi GroupsNameTasksIdTouchPost Post /groups/{name}/tasks/{id}/touch Extend task timeout.
TasksApi GroupsNameTasksPost Post /groups/{name}/tasks Enqueue task
TasksApi TasksGet Get /tasks Get next task.

Documentation For Models

Documentation For Authorization

All endpoints do not require authorization.

Author

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
}

func (*APIClient) CallAPI

func (c *APIClient) CallAPI(path string, method string,
	postBody interface{},
	headerParams map[string]string,
	queryParams url.Values,
	formParams map[string]string,
	fileName string,
	fileBytes []byte) (*resty.Response, error)

func (*APIClient) ParameterToString

func (c *APIClient) ParameterToString(obj interface{}, collectionFormat string) string

func (*APIClient) SelectHeaderAccept

func (c *APIClient) SelectHeaderAccept(accepts []string) string

func (*APIClient) SelectHeaderContentType

func (c *APIClient) SelectHeaderContentType(contentTypes []string) string

type APIResponse

type APIResponse struct {
	*http.Response
	Message string `json:"message,omitempty"`
}

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

type Complete

type Complete struct {

	// Time when task was completed. Always in UTC.
	CompletedAt time.Time `json:"completed_at,omitempty"`

	// Machine readable reason failure, if status=error. Only used by the /error endpoint.
	Reason string `json:"reason,omitempty"`

	// Error message, if status=error. Only used by the /error endpoint.
	Error_ string `json:"error,omitempty"`
}

type Configuration

type Configuration struct {
	UserName     string            `json:"userName,omitempty"`
	Password     string            `json:"password,omitempty"`
	APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"`
	APIKey       map[string]string `json:"APIKey,omitempty"`

	DebugFile     string            `json:"debugFile,omitempty"`
	OAuthToken    string            `json:"oAuthToken,omitempty"`
	Timeout       int               `json:"timeout,omitempty"`
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	AccessToken   string            `json:"accessToken,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	APIClient     APIClient         `json:"APIClient,omitempty"`
	// contains filtered or unexported fields
}

func NewConfiguration

func NewConfiguration() *Configuration

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

func (*Configuration) GetAPIKeyWithPrefix

func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string

func (*Configuration) GetBasicAuthEncodedString

func (c *Configuration) GetBasicAuthEncodedString() string

func (*Configuration) GetDebug

func (c *Configuration) GetDebug() bool

func (*Configuration) SetDebug

func (c *Configuration) SetDebug(enable bool)

type ErrorBody

type ErrorBody struct {
	Message string `json:"message,omitempty"`

	Fields string `json:"fields,omitempty"`
}

type Group

type Group struct {

	// Name of this group. Must be different than the image name. Can ony contain alphanumeric, -, and _.
	Name string `json:"name,omitempty"`

	// Time when image first used/created.
	CreatedAt time.Time `json:"created_at,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"`

	// User defined environment variables that will be passed in to each task in this group.
	EnvVars map[string]string `json:"env_vars,omitempty"`

	// The maximum number of tasks that will run at the exact same time in this group.
	MaxConcurrency int32 `json:"max_concurrency,omitempty"`
}

type GroupWrapper

type GroupWrapper struct {
	Group Group `json:"group,omitempty"`
}

type GroupsApi

type GroupsApi struct {
	Configuration Configuration
}

func NewGroupsApi

func NewGroupsApi() *GroupsApi

func NewGroupsApiWithBasePath

func NewGroupsApiWithBasePath(basePath string) *GroupsApi

func (GroupsApi) GroupsGet

func (a GroupsApi) GroupsGet() (*GroupsWrapper, *APIResponse, error)

*

  • Get all group names.
  • Get a list of all the groups in the system. *
  • @return *GroupsWrapper

func (GroupsApi) GroupsNameGet

func (a GroupsApi) GroupsNameGet(name string) (*GroupWrapper, *APIResponse, error)

*

  • Get information for a group.
  • This gives more details about a task group, such as statistics. *
  • @param name name of the group.
  • @return *GroupWrapper

func (GroupsApi) GroupsNamePut

func (a GroupsApi) GroupsNamePut(name string, body GroupWrapper) (*GroupWrapper, *APIResponse, error)

*

  • Create/update a task group.
  • You can set group level settings here. *
  • @param name name of the group.
  • @param body Group to post.
  • @return *GroupWrapper

func (GroupsApi) GroupsPost

func (a GroupsApi) GroupsPost(body GroupWrapper) (*GroupWrapper, *APIResponse, error)

*

  • Post new group
  • Insert a new task group *
  • @param body Group to post.
  • @return *GroupWrapper

type GroupsWrapper

type GroupsWrapper struct {
	Groups []Group `json:"groups,omitempty"`
}

type IdStatus

type IdStatus struct {

	// Unique identifier representing a specific task.
	Id string `json:"id,omitempty"`

	// States and valid transitions.                   +---------+        +---------> delayed <----------------+                  +----+----+                |                       |                     |                       |                     |                  +----v----+                |        +---------> queued  <----------------+                  +----+----+                *                       |                     *                       |               retry * creates new task                  +----v----+                *                  | running |                *                  +--+-+-+--+                |           +---------|-|-|-----+-------------+       +---|---------+ | +-----|---------+   |       |   |           |       |         |   | +-----v---^-+      +--v-------^+     +--v---^-+ | success   |      | cancelled |     |  error | +-----------+      +-----------+     +--------+  * delayed - has a delay. * queued - Ready to be consumed when it's turn comes. * running - Currently consumed by a runner which will attempt to process it. * success - (or complete? success/error is common javascript terminology) * error - Something went wrong. In this case more information can be obtained   by inspecting the \"reason\" field.   - timeout   - killed - forcibly killed by worker due to resource restrictions or access     violations.   - bad_exit - exited with non-zero status due to program termination/crash. * cancelled - cancelled via API. More information in the reason field.   - client_request - Request was cancelled by a client.
	Status string `json:"status,omitempty"`
}

type ModelError

type ModelError struct {
	Error_ ErrorBody `json:"error,omitempty"`
}

type NewTask

type NewTask struct {

	// Name of Docker image to use. This is optional and can be used to override the image defined at the group level.
	Image string `json:"image,omitempty"`

	// Payload for the task. This is what you pass into each task to make it do something.
	Payload string `json:"payload,omitempty"`

	// Number of seconds to wait before queueing the task for consumption for the first time. Must be a positive integer. Tasks with a delay start in state \"delayed\" and transition to \"running\" after delay seconds.
	Delay int32 `json:"delay,omitempty"`

	// Maximum runtime in seconds. If a consumer retrieves the task, but does not change it's status within timeout seconds, the task is considered failed, with reason timeout (Titan may allow a small grace period). The consumer should also kill the task after timeout seconds. If a consumer tries to change status after Titan has already timed out the task, the consumer will be ignored.
	Timeout int32 `json:"timeout,omitempty"`

	// Priority of the task. Higher has more priority. 3 levels from 0-2. Tasks at same priority are processed in FIFO order.
	Priority int32 `json:"priority,omitempty"`

	// \"Number of automatic retries this task 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 task with the same image id and payload. The new task's max_retries is one less than the original. The new task's `retry_of` field is set to the original Task ID. The old task's `retry_at` field is set to the new Task's ID.  Titan will delay the new task for retries_delay seconds before queueing it. Cancelled or successful tasks are never automatically retried.\"
	MaxRetries int32 `json:"max_retries,omitempty"`

	// Time in seconds to wait before retrying the task. Must be a non-negative integer.
	RetriesDelay int32 `json:"retries_delay,omitempty"`
}

type NewTasksWrapper

type NewTasksWrapper struct {
	Tasks []NewTask `json:"tasks,omitempty"`
}

type RunnerApi

type RunnerApi struct {
	Configuration Configuration
}

func NewRunnerApi

func NewRunnerApi() *RunnerApi

func NewRunnerApiWithBasePath

func NewRunnerApiWithBasePath(basePath string) *RunnerApi

func (RunnerApi) GroupsNameTasksIdErrorPost

func (a RunnerApi) GroupsNameTasksIdErrorPost(name string, id string, body Complete) (*TaskWrapper, *APIResponse, error)

*

  • Mark task as failed.
  • Task is marked as failed if it was in a valid state. Task&#39;s &#x60;finished_at&#x60; time is initialized. *
  • @param name Name of group for this set of tasks.
  • @param id Task id
  • @param body
  • @return *TaskWrapper

func (RunnerApi) GroupsNameTasksIdStartPost

func (a RunnerApi) GroupsNameTasksIdStartPost(name string, id string, body Start) (*TaskWrapper, *APIResponse, error)

*

  • Mark task as started, ie: status &#x3D; &#39;running&#39;
  • Task status is changed to &#39;running&#39; if it was in a valid state before. Task&#39;s &#x60;started_at&#x60; time is initialized. *
  • @param name Name of group for this set of tasks.
  • @param id Task id
  • @param body
  • @return *TaskWrapper

func (RunnerApi) GroupsNameTasksIdSuccessPost

func (a RunnerApi) GroupsNameTasksIdSuccessPost(name string, id string, body Complete) (*TaskWrapper, *APIResponse, error)

*

  • Mark task as succeeded.
  • Task status is changed to succeeded if it was in a valid state before. Task&#39;s &#x60;completed_at&#x60; time is initialized. *
  • @param name Name of group for this set of tasks.
  • @param id Task id
  • @param body
  • @return *TaskWrapper

type Start

type Start struct {

	// Time when task started execution. Always in UTC.
	StartedAt time.Time `json:"started_at,omitempty"`
}

type Task

type Task struct {

	// Name of Docker image to use. This is optional and can be used to override the image defined at the group level.
	Image string `json:"image,omitempty"`

	// Payload for the task. This is what you pass into each task to make it do something.
	Payload string `json:"payload,omitempty"`

	// Number of seconds to wait before queueing the task for consumption for the first time. Must be a positive integer. Tasks with a delay start in state \"delayed\" and transition to \"running\" after delay seconds.
	Delay int32 `json:"delay,omitempty"`

	// Maximum runtime in seconds. If a consumer retrieves the task, but does not change it's status within timeout seconds, the task is considered failed, with reason timeout (Titan may allow a small grace period). The consumer should also kill the task after timeout seconds. If a consumer tries to change status after Titan has already timed out the task, the consumer will be ignored.
	Timeout int32 `json:"timeout,omitempty"`

	// Priority of the task. Higher has more priority. 3 levels from 0-2. Tasks at same priority are processed in FIFO order.
	Priority int32 `json:"priority,omitempty"`

	// \"Number of automatic retries this task 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 task with the same image id and payload. The new task's max_retries is one less than the original. The new task's `retry_of` field is set to the original Task ID. The old task's `retry_at` field is set to the new Task's ID.  Titan will delay the new task for retries_delay seconds before queueing it. Cancelled or successful tasks are never automatically retried.\"
	MaxRetries int32 `json:"max_retries,omitempty"`

	// Time in seconds to wait before retrying the task. Must be a non-negative integer.
	RetriesDelay int32 `json:"retries_delay,omitempty"`

	// Unique identifier representing a specific task.
	Id string `json:"id,omitempty"`

	// States and valid transitions.                   +---------+        +---------> delayed <----------------+                  +----+----+                |                       |                     |                       |                     |                  +----v----+                |        +---------> queued  <----------------+                  +----+----+                *                       |                     *                       |               retry * creates new task                  +----v----+                *                  | running |                *                  +--+-+-+--+                |           +---------|-|-|-----+-------------+       +---|---------+ | +-----|---------+   |       |   |           |       |         |   | +-----v---^-+      +--v-------^+     +--v---^-+ | success   |      | cancelled |     |  error | +-----------+      +-----------+     +--------+  * delayed - has a delay. * queued - Ready to be consumed when it's turn comes. * running - Currently consumed by a runner which will attempt to process it. * success - (or complete? success/error is common javascript terminology) * error - Something went wrong. In this case more information can be obtained   by inspecting the \"reason\" field.   - timeout   - killed - forcibly killed by worker due to resource restrictions or access     violations.   - bad_exit - exited with non-zero status due to program termination/crash. * cancelled - cancelled via API. More information in the reason field.   - client_request - Request was cancelled by a client.
	Status string `json:"status,omitempty"`

	// Group this task belongs to.
	GroupName string `json:"group_name,omitempty"`

	// The error message, if status is 'error'. This is errors due to things outside the task itself. Errors from user code will be found in the log.
	Error_ string `json:"error,omitempty"`

	// Machine usable reason for task being in this state. Valid values for error status are `timeout | killed | bad_exit`. Valid values for cancelled status are `client_request`. For everything else, this is undefined.
	Reason string `json:"reason,omitempty"`

	// Time when task was submitted. Always in UTC.
	CreatedAt time.Time `json:"created_at,omitempty"`

	// Time when task started execution. Always in UTC.
	StartedAt time.Time `json:"started_at,omitempty"`

	// Time when task completed, whether it was successul or failed. Always in UTC.
	CompletedAt time.Time `json:"completed_at,omitempty"`

	// If this field is set, then this task is a retry of the ID in this field.
	RetryOf string `json:"retry_of,omitempty"`

	// If this field is set, then this task was retried by the task referenced in this field.
	RetryAt string `json:"retry_at,omitempty"`

	// Env vars for the task. Comes from the ones set on the Group.
	EnvVars map[string]string `json:"env_vars,omitempty"`
}

type TaskWrapper

type TaskWrapper struct {
	Task Task `json:"task,omitempty"`
}

type TasksApi

type TasksApi struct {
	Configuration Configuration
}

func NewTasksApi

func NewTasksApi() *TasksApi

func NewTasksApiWithBasePath

func NewTasksApiWithBasePath(basePath string) *TasksApi

func (TasksApi) GroupsNameTasksGet

func (a TasksApi) GroupsNameTasksGet(name string, createdAfter time.Time, n int32, cursor string) (*TasksWrapper, *APIResponse, error)

*

  • Get task list by group name.
  • This will list tasks for a particular group. *
  • @param name Name of group for this set of tasks.
  • @param createdAfter Will return tasks created after this time. In RFC3339 format.
  • @param n Number of tasks to return per page. Default is 50. Max is 1000.
  • @param cursor Pass this in from a previous query to paginate results.
  • @return *TasksWrapper

func (TasksApi) GroupsNameTasksIdCancelPost

func (a TasksApi) GroupsNameTasksIdCancelPost(name string, id string) (*TaskWrapper, *APIResponse, error)

*

  • Cancel a task.
  • Cancels a task in delayed, queued or running status. The worker may continue to run a running task. reason is set to &#x60;client_request&#x60;. The task&#39;s completed_at field is set to the current time on the taskserver. *
  • @param name Name of group for this set of tasks.
  • @param id Task id
  • @return *TaskWrapper

func (TasksApi) GroupsNameTasksIdDelete

func (a TasksApi) GroupsNameTasksIdDelete(name string, id string) (*APIResponse, error)

*

  • Delete the task.
  • Delete only succeeds if task status is one of &#x60;succeeded | failed | cancelled&#x60;. Cancel a task if it is another state and needs to be deleted. All information about the task, including the log, is irretrievably lost when this is invoked. *
  • @param name Name of group for this set of tasks.
  • @param id Task id
  • @return void

func (TasksApi) GroupsNameTasksIdErrorPost

func (a TasksApi) GroupsNameTasksIdErrorPost(name string, id string, body Complete) (*TaskWrapper, *APIResponse, error)

*

  • Mark task as failed.
  • Task is marked as failed if it was in a valid state. Task&#39;s &#x60;finished_at&#x60; time is initialized. *
  • @param name Name of group for this set of tasks.
  • @param id Task id
  • @param body
  • @return *TaskWrapper

func (TasksApi) GroupsNameTasksIdGet

func (a TasksApi) GroupsNameTasksIdGet(name string, id string) (*TaskWrapper, *APIResponse, error)

*

  • Gets task by id
  • Gets a task by id. *
  • @param name Name of group for this set of tasks.
  • @param id task id
  • @return *TaskWrapper

func (TasksApi) GroupsNameTasksIdLogGet

func (a TasksApi) GroupsNameTasksIdLogGet(name string, id string) (*string, *APIResponse, error)

*

  • Get the log of a completed task.
  • Retrieves the log from log storage. *
  • @param name Name of group for this set of tasks.
  • @param id Task id
  • @return *string

func (TasksApi) GroupsNameTasksIdLogPost

func (a TasksApi) GroupsNameTasksIdLogPost(name string, id string, log *os.File) (*TaskWrapper, *APIResponse, error)

*

  • Send in a log for storage.
  • Logs are sent after a task completes since they may be very large and the runner can process the next task. *
  • @param name Name of group for this set of tasks.
  • @param id Task id
  • @param log Output log for the task. Content-Type must be \&quot;text/plain; charset&#x3D;utf-8\&quot;.
  • @return *TaskWrapper

func (TasksApi) GroupsNameTasksIdRetryPost

func (a TasksApi) GroupsNameTasksIdRetryPost(name string, id string) (*TaskWrapper, *APIResponse, error)

*

  • Retry a task.
  • \&quot;The /retry endpoint can be used to force a retry of tasks with status succeeded, cancelled or failed. The retried task has the same attributes. max_retries is not modified.\&quot; *
  • @param name Name of group for this set of tasks.
  • @param id Task id
  • @return *TaskWrapper

func (TasksApi) GroupsNameTasksIdStartPost

func (a TasksApi) GroupsNameTasksIdStartPost(name string, id string, body Start) (*TaskWrapper, *APIResponse, error)

*

  • Mark task as started, ie: status &#x3D; &#39;running&#39;
  • Task status is changed to &#39;running&#39; if it was in a valid state before. Task&#39;s &#x60;started_at&#x60; time is initialized. *
  • @param name Name of group for this set of tasks.
  • @param id Task id
  • @param body
  • @return *TaskWrapper

func (TasksApi) GroupsNameTasksIdSuccessPost

func (a TasksApi) GroupsNameTasksIdSuccessPost(name string, id string, body Complete) (*TaskWrapper, *APIResponse, error)

*

  • Mark task as succeeded.
  • Task status is changed to succeeded if it was in a valid state before. Task&#39;s &#x60;completed_at&#x60; time is initialized. *
  • @param name Name of group for this set of tasks.
  • @param id Task id
  • @param body
  • @return *TaskWrapper

func (TasksApi) GroupsNameTasksIdTouchPost

func (a TasksApi) GroupsNameTasksIdTouchPost(name string, id string) (*APIResponse, error)

*

  • Extend task timeout.
  • Consumers can sometimes take a while to run the task after accepting it. An example is when the runner does not have the docker image locally, it can spend a significant time downloading the image. If the timeout is small, the task may never get to run, or run but not be accepted by Titan. Consumers can touch the task before it times out. Titan will reset the timeout, giving the consumer another timeout seconds to run the task. Touch is only valid while the task is in a running state. If touch fails, the runner may stop running the task. *
  • @param name Name of group for this set of tasks.
  • @param id Task id
  • @return void

func (TasksApi) GroupsNameTasksPost

func (a TasksApi) GroupsNameTasksPost(name string, body NewTasksWrapper) (*TasksWrapper, *APIResponse, error)

*

  • Enqueue task
  • Enqueues task(s). If any of the tasks is invalid, none of the tasks are enqueued. *
  • @param name name of the group.
  • @param body Array of tasks to post.
  • @return *TasksWrapper

func (TasksApi) TasksGet

func (a TasksApi) TasksGet(n int32) (*TasksWrapper, *APIResponse, error)

*

  • Get next task.
  • Gets the next task in the queue, ready for processing. Titan may return &lt;&#x3D;n tasks. Consumers should start processing tasks in order. Each returned task is set to &#x60;status&#x60; \&quot;running\&quot; and &#x60;started_at&#x60; is set to the current time. No other consumer can retrieve this task. *
  • @param n Number of tasks to return.
  • @return *TasksWrapper

type TasksWrapper

type TasksWrapper struct {
	Tasks []Task `json:"tasks,omitempty"`

	// Used to paginate results. If this is returned, pass it into the same query again to get more results.
	Cursor string `json:"cursor,omitempty"`

	Error_ ErrorBody `json:"error,omitempty"`
}

Jump to

Keyboard shortcuts

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