github.com/iron-io/functions@v0.0.0-20180820112432-d59d7d1c40b2/api/models/new_task.go (about) 1 package models 2 3 // This file was generated by the swagger tool. 4 // Editing this file might prove futile when you re-run the swagger generate command 5 6 import ( 7 strfmt "github.com/go-openapi/strfmt" 8 9 "github.com/go-openapi/errors" 10 "github.com/go-openapi/validate" 11 ) 12 13 /*NewTask new task 14 15 swagger:model NewTask 16 */ 17 type NewTask struct { 18 19 /* 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. 20 */ 21 Delay int32 `json:"delay,omitempty"` 22 23 /* Name of Docker image to use. This is optional and can be used to override the image defined at the route level. 24 25 Required: true 26 */ 27 Image *string `json:"image"` 28 29 /* "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." 30 31 */ 32 MaxRetries int32 `json:"max_retries,omitempty"` 33 34 /* Payload for the task. This is what you pass into each task to make it do something. 35 */ 36 Payload string `json:"payload,omitempty"` 37 38 /* Priority of the task. Higher has more priority. 3 levels from 0-2. Tasks at same priority are processed in FIFO order. 39 40 Required: true 41 */ 42 Priority *int32 `json:"priority"` 43 44 /* Time in seconds to wait before retrying the task. Must be a non-negative integer. 45 */ 46 RetriesDelay *int32 `json:"retries_delay,omitempty"` 47 48 /* Maximum runtime in seconds. If a consumer retrieves the 49 task, but does not change it's status within timeout seconds, the task 50 is considered failed, with reason timeout (Titan may allow a small 51 grace period). The consumer should also kill the task after timeout 52 seconds. If a consumer tries to change status after Titan has already 53 timed out the task, the consumer will be ignored. 54 55 */ 56 Timeout *int32 `json:"timeout,omitempty"` 57 58 /* Hot function idle timeout in seconds before termination. 59 60 */ 61 IdleTimeout *int32 `json:"idle_timeout,omitempty"` 62 } 63 64 // Validate validates this new task 65 func (m *NewTask) Validate(formats strfmt.Registry) error { 66 var res []error 67 68 if err := m.validateImage(formats); err != nil { 69 // prop 70 res = append(res, err) 71 } 72 73 if err := m.validatePriority(formats); err != nil { 74 // prop 75 res = append(res, err) 76 } 77 78 if len(res) > 0 { 79 return errors.CompositeValidationError(res...) 80 } 81 return nil 82 } 83 84 func (m *NewTask) validateImage(formats strfmt.Registry) error { 85 86 if err := validate.Required("image", "body", m.Image); err != nil { 87 return err 88 } 89 90 return nil 91 } 92 93 func (m *NewTask) validatePriority(formats strfmt.Registry) error { 94 95 if err := validate.Required("priority", "body", m.Priority); err != nil { 96 return err 97 } 98 99 return nil 100 }