task

package
v1.31.0-release.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2019 License: BSD-2-Clause Imports: 11 Imported by: 13

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func ErrorValueStringAsIDNotValid added in v1.27.0

func ErrorValueStringAsIDNotValid(value string) error

func IDValidator added in v1.27.0

func IDValidator(value string, errorReporter structure.ErrorReporter)

func IsValidID added in v1.27.0

func IsValidID(value string) bool

func NewID added in v1.27.0

func NewID() string

func TaskStates

func TaskStates() []string

func ValidateID added in v1.27.0

func ValidateID(value string) error

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) MutateRequest added in v1.27.0

func (t *TaskFilter) MutateRequest(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) IsEmpty added in v1.31.0

func (t *TaskUpdate) IsEmpty() 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