backends

package
v0.0.0-...-a549144 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2016 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PendingState - initial state of a task
	PendingState = "PENDING"
	// ReceivedState - when task is received by a worker
	ReceivedState = "RECEIVED"
	// StartedState - when the worker starts processing the task
	StartedState = "STARTED"
	// SuccessState - when the task is processed successfully
	SuccessState = "SUCCESS"
	// FailureState - when processing of the task fails
	FailureState = "FAILURE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AMQPBackend

type AMQPBackend struct {
	// contains filtered or unexported fields
}

AMQPBackend represents an AMQP result backend

func (*AMQPBackend) GetState

func (amqpBackend *AMQPBackend) GetState(taskUUID string) (*TaskState, error)

GetState - returns the latest task state. It will only return the status once as the message will get consumed and removed from the queue.

func (*AMQPBackend) GroupCompleted

func (amqpBackend *AMQPBackend) GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)

GroupCompleted - returns true if all tasks in a group finished NOTE: Given AMQP limitation this will only return true if all finished tasks were successful as we do not keep track of completed failed tasks

func (*AMQPBackend) GroupTaskStates

func (amqpBackend *AMQPBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*TaskState, error)

GroupTaskStates - returns states of all tasks in the group

func (*AMQPBackend) InitGroup

func (amqpBackend *AMQPBackend) InitGroup(groupUUID string, taskUUIDs []string) error

InitGroup - saves UUIDs of all tasks in a group

func (*AMQPBackend) PurgeGroupMeta

func (amqpBackend *AMQPBackend) PurgeGroupMeta(groupUUID string) error

PurgeGroupMeta - deletes stored group meta data

func (*AMQPBackend) PurgeState

func (amqpBackend *AMQPBackend) PurgeState(taskUUID string) error

PurgeState - deletes stored task state

func (*AMQPBackend) SetStateFailure

func (amqpBackend *AMQPBackend) SetStateFailure(signature *signatures.TaskSignature, err string) error

SetStateFailure - sets task state to FAILURE

func (*AMQPBackend) SetStatePending

func (amqpBackend *AMQPBackend) SetStatePending(signature *signatures.TaskSignature) error

SetStatePending - sets task state to PENDING

func (*AMQPBackend) SetStateReceived

func (amqpBackend *AMQPBackend) SetStateReceived(signature *signatures.TaskSignature) error

SetStateReceived - sets task state to RECEIVED

func (*AMQPBackend) SetStateStarted

func (amqpBackend *AMQPBackend) SetStateStarted(signature *signatures.TaskSignature) error

SetStateStarted - sets task state to STARTED

func (*AMQPBackend) SetStateSuccess

func (amqpBackend *AMQPBackend) SetStateSuccess(signature *signatures.TaskSignature, result *TaskResult) error

SetStateSuccess - sets task state to SUCCESS

type AsyncResult

type AsyncResult struct {
	Signature *signatures.TaskSignature
	// contains filtered or unexported fields
}

AsyncResult represents a task result

func NewAsyncResult

func NewAsyncResult(signature *signatures.TaskSignature, backend Backend) *AsyncResult

NewAsyncResult creates AsyncResult instance

func (*AsyncResult) Get

func (asyncResult *AsyncResult) Get() (reflect.Value, error)

Get returns task result (synchronous blocking call)

func (*AsyncResult) GetState

func (asyncResult *AsyncResult) GetState() *TaskState

GetState returns latest task state

type Backend

type Backend interface {
	// Group related functions
	InitGroup(groupUUID string, taskUUIDs []string) error
	GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)
	GroupTaskStates(groupUUID string, groupTaskCount int) ([]*TaskState, error)
	// Setting / getting task state
	SetStatePending(signature *signatures.TaskSignature) error
	SetStateReceived(signature *signatures.TaskSignature) error
	SetStateStarted(signature *signatures.TaskSignature) error
	SetStateSuccess(signature *signatures.TaskSignature, result *TaskResult) error
	SetStateFailure(signature *signatures.TaskSignature, err string) error
	GetState(taskUUID string) (*TaskState, error)
	// Purging stored stored tasks states and group meta data
	PurgeState(taskUUID string) error
	PurgeGroupMeta(groupUUID string) error
}

Backend - a common interface for all result backends

func NewAMQPBackend

func NewAMQPBackend(cnf *config.Config) Backend

NewAMQPBackend creates AMQPBackend instance

func NewEagerBackend

func NewEagerBackend() Backend

func NewMemcacheBackend

func NewMemcacheBackend(cnf *config.Config, servers []string) Backend

NewMemcacheBackend creates MemcacheBackend instance

func NewRedisBackend

func NewRedisBackend(cnf *config.Config, host, password string) Backend

NewRedisBackend creates RedisBackend instance

type ChainAsyncResult

type ChainAsyncResult struct {
	// contains filtered or unexported fields
}

ChainAsyncResult represents a result of a chain of tasks

func NewChainAsyncResult

func NewChainAsyncResult(tasks []*signatures.TaskSignature, backend Backend) *ChainAsyncResult

NewChainAsyncResult creates ChainAsyncResult instance

func (*ChainAsyncResult) Get

func (chainAsyncResult *ChainAsyncResult) Get() (reflect.Value, error)

Get returns result of a chain of tasks (synchronous blocking call)

type ChordAsyncResult

type ChordAsyncResult struct {
	// contains filtered or unexported fields
}

ChordAsyncResult represents a result of a chord

func NewChordAsyncResult

func NewChordAsyncResult(groupTasks []*signatures.TaskSignature, chordCallback *signatures.TaskSignature, backend Backend) *ChordAsyncResult

NewChordAsyncResult creates ChordAsyncResult instance

func (*ChordAsyncResult) Get

func (chordAsyncResult *ChordAsyncResult) Get() (reflect.Value, error)

Get returns result of a chord (synchronous blocking call)

type EagerBackend

type EagerBackend struct {
	// contains filtered or unexported fields
}

func (*EagerBackend) GetState

func (e *EagerBackend) GetState(taskUUID string) (*TaskState, error)

func (*EagerBackend) GroupCompleted

func (e *EagerBackend) GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)

func (*EagerBackend) GroupTaskStates

func (e *EagerBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*TaskState, error)

func (*EagerBackend) InitGroup

func (e *EagerBackend) InitGroup(groupUUID string, taskUUIDs []string) error

func (*EagerBackend) PurgeGroupMeta

func (e *EagerBackend) PurgeGroupMeta(groupUUID string) error

func (*EagerBackend) PurgeState

func (e *EagerBackend) PurgeState(taskUUID string) error

func (*EagerBackend) SetStateFailure

func (e *EagerBackend) SetStateFailure(signature *signatures.TaskSignature, err string) error

func (*EagerBackend) SetStatePending

func (e *EagerBackend) SetStatePending(signature *signatures.TaskSignature) error

func (*EagerBackend) SetStateReceived

func (e *EagerBackend) SetStateReceived(signature *signatures.TaskSignature) error

func (*EagerBackend) SetStateStarted

func (e *EagerBackend) SetStateStarted(signature *signatures.TaskSignature) error

func (*EagerBackend) SetStateSuccess

func (e *EagerBackend) SetStateSuccess(signature *signatures.TaskSignature, result *TaskResult) error

type GroupMeta

type GroupMeta struct {
	GroupUUID string
	TaskUUIDs []string
}

GroupMeta stores useful metadata about tasks within the same group E.g. UUIDs of all tasks which are used in order to check if all tasks completed successfully or not and thus whether to trigger chord callback

type MemcacheBackend

type MemcacheBackend struct {
	// contains filtered or unexported fields
}

MemcacheBackend represents a Memcache result backend

func (*MemcacheBackend) GetState

func (memcacheBackend *MemcacheBackend) GetState(taskUUID string) (*TaskState, error)

GetState - returns the latest task state

func (*MemcacheBackend) GroupCompleted

func (memcacheBackend *MemcacheBackend) GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)

GroupCompleted - returns true if all tasks in a group finished

func (*MemcacheBackend) GroupTaskStates

func (memcacheBackend *MemcacheBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*TaskState, error)

GroupTaskStates - returns states of all tasks in the group

func (*MemcacheBackend) InitGroup

func (memcacheBackend *MemcacheBackend) InitGroup(groupUUID string, taskUUIDs []string) error

InitGroup - saves UUIDs of all tasks in a group

func (*MemcacheBackend) PurgeGroupMeta

func (memcacheBackend *MemcacheBackend) PurgeGroupMeta(groupUUID string) error

PurgeGroupMeta - deletes stored group meta data

func (*MemcacheBackend) PurgeState

func (memcacheBackend *MemcacheBackend) PurgeState(taskUUID string) error

PurgeState - deletes stored task state

func (*MemcacheBackend) SetStateFailure

func (memcacheBackend *MemcacheBackend) SetStateFailure(signature *signatures.TaskSignature, err string) error

SetStateFailure - sets task state to FAILURE

func (*MemcacheBackend) SetStatePending

func (memcacheBackend *MemcacheBackend) SetStatePending(signature *signatures.TaskSignature) error

SetStatePending - sets task state to PENDING

func (*MemcacheBackend) SetStateReceived

func (memcacheBackend *MemcacheBackend) SetStateReceived(signature *signatures.TaskSignature) error

SetStateReceived - sets task state to RECEIVED

func (*MemcacheBackend) SetStateStarted

func (memcacheBackend *MemcacheBackend) SetStateStarted(signature *signatures.TaskSignature) error

SetStateStarted - sets task state to STARTED

func (*MemcacheBackend) SetStateSuccess

func (memcacheBackend *MemcacheBackend) SetStateSuccess(signature *signatures.TaskSignature, result *TaskResult) error

SetStateSuccess - sets task state to SUCCESS

type RedisBackend

type RedisBackend struct {
	// contains filtered or unexported fields
}

RedisBackend represents a Memcache result backend

func (*RedisBackend) GetState

func (redisBackend *RedisBackend) GetState(taskUUID string) (*TaskState, error)

GetState - returns the latest task state

func (*RedisBackend) GroupCompleted

func (redisBackend *RedisBackend) GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)

GroupCompleted - returns true if all tasks in a group finished

func (*RedisBackend) GroupTaskStates

func (redisBackend *RedisBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*TaskState, error)

GroupTaskStates - returns states of all tasks in the group

func (*RedisBackend) InitGroup

func (redisBackend *RedisBackend) InitGroup(groupUUID string, taskUUIDs []string) error

InitGroup - saves UUIDs of all tasks in a group

func (*RedisBackend) PurgeGroupMeta

func (redisBackend *RedisBackend) PurgeGroupMeta(groupUUID string) error

PurgeGroupMeta - deletes stored group meta data

func (*RedisBackend) PurgeState

func (redisBackend *RedisBackend) PurgeState(taskUUID string) error

PurgeState - deletes stored task state

func (*RedisBackend) SetStateFailure

func (redisBackend *RedisBackend) SetStateFailure(signature *signatures.TaskSignature, err string) error

SetStateFailure - sets task state to FAILURE

func (*RedisBackend) SetStatePending

func (redisBackend *RedisBackend) SetStatePending(signature *signatures.TaskSignature) error

SetStatePending - sets task state to PENDING

func (*RedisBackend) SetStateReceived

func (redisBackend *RedisBackend) SetStateReceived(signature *signatures.TaskSignature) error

SetStateReceived - sets task state to RECEIVED

func (*RedisBackend) SetStateStarted

func (redisBackend *RedisBackend) SetStateStarted(signature *signatures.TaskSignature) error

SetStateStarted - sets task state to STARTED

func (*RedisBackend) SetStateSuccess

func (redisBackend *RedisBackend) SetStateSuccess(signature *signatures.TaskSignature, result *TaskResult) error

SetStateSuccess - sets task state to SUCCESS

type TaskResult

type TaskResult struct {
	Type  string
	Value interface{}
}

TaskResult represents an actual return value of a processed task

type TaskState

type TaskState struct {
	TaskUUID string
	State    string
	Result   *TaskResult
	Error    string
}

TaskState represents a state of a task

func NewFailureTaskState

func NewFailureTaskState(signature *signatures.TaskSignature, err string) *TaskState

NewFailureTaskState ...

func NewPendingTaskState

func NewPendingTaskState(signature *signatures.TaskSignature) *TaskState

NewPendingTaskState ...

func NewReceivedTaskState

func NewReceivedTaskState(signature *signatures.TaskSignature) *TaskState

NewReceivedTaskState ...

func NewStartedTaskState

func NewStartedTaskState(signature *signatures.TaskSignature) *TaskState

NewStartedTaskState ...

func NewSuccessTaskState

func NewSuccessTaskState(signature *signatures.TaskSignature, result *TaskResult) *TaskState

NewSuccessTaskState ...

func (*TaskState) IsCompleted

func (taskState *TaskState) IsCompleted() bool

IsCompleted returns true if state is SUCCESSS or FAILURE, i.e. the task has finished processing and either succeeded or failed.

func (*TaskState) IsFailure

func (taskState *TaskState) IsFailure() bool

IsFailure returns true if state is FAILURE

func (*TaskState) IsSuccess

func (taskState *TaskState) IsSuccess() bool

IsSuccess returns true if state is SUCCESSS

Jump to

Keyboard shortcuts

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