task

package
v1.22.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2018 License: BSD-3-Clause Imports: 11 Imported by: 13

Documentation

Index

Constants

View Source
const (
	TaskStatePending   = "pending"
	TaskStateRunning   = "running"
	TaskStateFailed    = "failed"
	TaskStateCompleted = "completed"
)

Variables

Functions

This section is empty.

Types

type Client

type Client interface {
	TaskAccessor
}

type Task

type Task struct {
	ID             string                 `json:"id,omitempty" bson:"id,omitempty"`
	Name           *string                `json:"name,omitempty" bson:"name,omitempty"`
	Type           string                 `json:"type,omitempty" bson:"type,omitempty"`
	Priority       int                    `json:"priority,omitempty" bson:"priority,omitempty"`
	Data           map[string]interface{} `json:"data,omitempty" bson:"data,omitempty"`
	AvailableTime  *time.Time             `json:"availableTime,omitempty" bson:"availableTime,omitempty"`
	ExpirationTime *time.Time             `json:"expirationTime,omitempty" bson:"expirationTime,omitempty"`
	State          string                 `json:"state,omitempty" bson:"state,omitempty"`
	Error          *errors.Serializable   `json:"error,omitempty" bson:"error,omitempty"`
	RunTime        *time.Time             `json:"runTime,omitempty" bson:"runTime,omitempty"`
	Duration       *float64               `json:"duration,omitempty" bson:"duration,omitempty"`
	CreatedTime    time.Time              `json:"createdTime,omitempty" bson:"createdTime,omitempty"`
	ModifiedTime   *time.Time             `json:"modifiedTime,omitempty" bson:"modifiedTime,omitempty"`
}

func NewTask

func NewTask(create *TaskCreate) (*Task, error)

func (*Task) AppendError

func (t *Task) AppendError(err error)

func (*Task) ClearError

func (t *Task) ClearError()

func (*Task) HasError

func (t *Task) HasError() bool

func (*Task) IsCompleted

func (t *Task) IsCompleted() bool

func (*Task) IsFailed

func (t *Task) IsFailed() bool

func (*Task) Normalize

func (t *Task) Normalize(normalizer structure.Normalizer)

func (*Task) Parse

func (t *Task) Parse(parser structure.ObjectParser)

func (*Task) RepeatAvailableAfter

func (t *Task) RepeatAvailableAfter(availableDuration time.Duration)

func (*Task) RepeatAvailableAt

func (t *Task) RepeatAvailableAt(availableTime time.Time)

func (*Task) Sanitize

func (t *Task) Sanitize(details request.Details) error

func (*Task) SetCompleted

func (t *Task) SetCompleted()

func (*Task) SetFailed

func (t *Task) SetFailed()

func (*Task) Validate

func (t *Task) Validate(validator structure.Validator)

type TaskAccessor

type TaskAccessor interface {
	ListTasks(ctx context.Context, filter *TaskFilter, pagination *page.Pagination) (Tasks, error)
	CreateTask(ctx context.Context, create *TaskCreate) (*Task, error)
	GetTask(ctx context.Context, id string) (*Task, error)
	UpdateTask(ctx context.Context, id string, update *TaskUpdate) (*Task, error)
	DeleteTask(ctx context.Context, id string) error
}

type TaskCreate

type TaskCreate struct {
	Name           *string                `json:"name,omitempty"`
	Type           string                 `json:"type,omitempty"`
	Priority       int                    `json:"priority,omitempty"`
	Data           map[string]interface{} `json:"data,omitempty"`
	AvailableTime  *time.Time             `json:"availableTime,omitempty"`
	ExpirationTime *time.Time             `json:"expirationTime,omitempty"`
}

func NewTaskCreate

func NewTaskCreate() *TaskCreate

func (*TaskCreate) Parse

func (t *TaskCreate) Parse(parser structure.ObjectParser)

func (*TaskCreate) Validate

func (t *TaskCreate) Validate(validator structure.Validator)

type TaskFilter

type TaskFilter struct {
	Name  *string `json:"name,omitempty"`
	Type  *string `json:"type,omitempty"`
	State *string `json:"state,omitempty"`
}

func NewTaskFilter

func NewTaskFilter() *TaskFilter

func (*TaskFilter) Mutate

func (t *TaskFilter) Mutate(req *http.Request) error

func (*TaskFilter) Parse

func (t *TaskFilter) Parse(parser structure.ObjectParser)

func (*TaskFilter) Validate

func (t *TaskFilter) Validate(validator structure.Validator)

type TaskUpdate

type TaskUpdate struct {
	Priority       *int                    `json:"priority,omitempty" bson:"priority,omitempty"`
	Data           *map[string]interface{} `json:"data,omitempty" bson:"data,omitempty"`
	AvailableTime  *time.Time              `json:"availableTime,omitempty" bson:"availableTime,omitempty"`
	ExpirationTime *time.Time              `json:"expirationTime,omitempty" bson:"expirationTime,omitempty"`
}

func NewTaskUpdate

func NewTaskUpdate() *TaskUpdate

func (*TaskUpdate) HasUpdates

func (t *TaskUpdate) HasUpdates() bool

func (*TaskUpdate) Parse

func (t *TaskUpdate) Parse(parser structure.ObjectParser)

func (*TaskUpdate) Validate

func (t *TaskUpdate) Validate(validator structure.Validator)

type Tasks

type Tasks []*Task

func (Tasks) Sanitize

func (t Tasks) Sanitize(details request.Details) error

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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