backends

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2017 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBackendNotConfigured ...
	ErrBackendNotConfigured = errors.New("Result backend not configured")
	// ErrTimeoutReached ...
	ErrTimeoutReached = errors.New("Timeout reached")
)

Functions

func IsAMQP added in v1.0.10

func IsAMQP(backend Interface) bool

IsAMQP returns true if the backend is AMQP

Types

type AMQPBackend

type AMQPBackend struct {
	Backend
	common.AMQPConnector
}

AMQPBackend represents an AMQP result backend

func (*AMQPBackend) GetState

func (b *AMQPBackend) GetState(taskUUID string) (*tasks.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 (b *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 (b *AMQPBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*tasks.TaskState, error)

GroupTaskStates returns states of all tasks in the group

func (*AMQPBackend) InitGroup

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

InitGroup creates and saves a group meta data object

func (*AMQPBackend) PurgeGroupMeta

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

PurgeGroupMeta deletes stored group meta data

func (*AMQPBackend) PurgeState

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

PurgeState deletes stored task state

func (*AMQPBackend) SetStateFailure

func (b *AMQPBackend) SetStateFailure(signature *tasks.Signature, err string) error

SetStateFailure updates task state to FAILURE

func (*AMQPBackend) SetStatePending

func (b *AMQPBackend) SetStatePending(signature *tasks.Signature) error

SetStatePending updates task state to PENDING

func (*AMQPBackend) SetStateReceived

func (b *AMQPBackend) SetStateReceived(signature *tasks.Signature) error

SetStateReceived updates task state to RECEIVED

func (*AMQPBackend) SetStateRetry

func (b *AMQPBackend) SetStateRetry(signature *tasks.Signature) error

SetStateRetry updates task state to RETRY

func (*AMQPBackend) SetStateStarted

func (b *AMQPBackend) SetStateStarted(signature *tasks.Signature) error

SetStateStarted updates task state to STARTED

func (*AMQPBackend) SetStateSuccess

func (b *AMQPBackend) SetStateSuccess(signature *tasks.Signature, results []*tasks.TaskResult) error

SetStateSuccess updates task state to SUCCESS

func (*AMQPBackend) TriggerChord

func (b *AMQPBackend) TriggerChord(groupUUID string) (bool, error)

TriggerChord flags chord as triggered in the backend storage to make sure chord is never trigerred multiple times. Returns a boolean flag to indicate whether the worker should trigger chord (true) or no if it has been triggered already (false)

type AsyncResult

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

AsyncResult represents a task result

func NewAsyncResult

func NewAsyncResult(signature *tasks.Signature, backend Interface) *AsyncResult

NewAsyncResult creates AsyncResult instance

func (*AsyncResult) Get

func (asyncResult *AsyncResult) Get(sleepDuration time.Duration) ([]reflect.Value, error)

Get returns task results (synchronous blocking call)

func (*AsyncResult) GetState

func (asyncResult *AsyncResult) GetState() *tasks.TaskState

GetState returns latest task state

func (*AsyncResult) GetWithTimeout

func (asyncResult *AsyncResult) GetWithTimeout(timeoutDuration, sleepDuration time.Duration) ([]reflect.Value, error)

GetWithTimeout returns task results with a timeout (synchronous blocking call)

func (*AsyncResult) Touch

func (asyncResult *AsyncResult) Touch() ([]reflect.Value, error)

Touch the state and don't wait

type Backend added in v1.0.10

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

Backend represents a base backend structure

func New added in v1.0.10

func New(cnf *config.Config) Backend

New creates new Backend 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 []*tasks.Signature, backend Interface) *ChainAsyncResult

NewChainAsyncResult creates ChainAsyncResult instance

func (*ChainAsyncResult) Get

func (chainAsyncResult *ChainAsyncResult) Get(sleepDuration time.Duration) ([]reflect.Value, error)

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

func (*ChainAsyncResult) GetWithTimeout

func (chainAsyncResult *ChainAsyncResult) GetWithTimeout(timeoutDuration, sleepDuration time.Duration) ([]reflect.Value, error)

GetWithTimeout returns results of a chain of tasks with timeout (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 []*tasks.Signature, chordCallback *tasks.Signature, backend Interface) *ChordAsyncResult

NewChordAsyncResult creates ChordAsyncResult instance

func (*ChordAsyncResult) Get

func (chordAsyncResult *ChordAsyncResult) Get(sleepDuration time.Duration) ([]reflect.Value, error)

Get returns result of a chord (synchronous blocking call)

func (*ChordAsyncResult) GetWithTimeout

func (chordAsyncResult *ChordAsyncResult) GetWithTimeout(timeoutDuration, sleepDuration time.Duration) ([]reflect.Value, error)

GetWithTimeout returns result of a chord with a timeout (synchronous blocking call)

type EagerBackend

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

EagerBackend represents an "eager" in-memory result backend

func (*EagerBackend) GetState

func (b *EagerBackend) GetState(taskUUID string) (*tasks.TaskState, error)

GetState returns the latest task state

func (*EagerBackend) GroupCompleted

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

GroupCompleted returns true if all tasks in a group finished

func (*EagerBackend) GroupTaskStates

func (b *EagerBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*tasks.TaskState, error)

GroupTaskStates returns states of all tasks in the group

func (*EagerBackend) InitGroup

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

InitGroup creates and saves a group meta data object

func (*EagerBackend) PurgeGroupMeta

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

PurgeGroupMeta deletes stored group meta data

func (*EagerBackend) PurgeState

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

PurgeState deletes stored task state

func (*EagerBackend) SetStateFailure

func (b *EagerBackend) SetStateFailure(signature *tasks.Signature, err string) error

SetStateFailure updates task state to FAILURE

func (*EagerBackend) SetStatePending

func (b *EagerBackend) SetStatePending(signature *tasks.Signature) error

SetStatePending updates task state to PENDING

func (*EagerBackend) SetStateReceived

func (b *EagerBackend) SetStateReceived(signature *tasks.Signature) error

SetStateReceived updates task state to RECEIVED

func (*EagerBackend) SetStateRetry

func (b *EagerBackend) SetStateRetry(signature *tasks.Signature) error

SetStateRetry updates task state to RETRY

func (*EagerBackend) SetStateStarted

func (b *EagerBackend) SetStateStarted(signature *tasks.Signature) error

SetStateStarted updates task state to STARTED

func (*EagerBackend) SetStateSuccess

func (b *EagerBackend) SetStateSuccess(signature *tasks.Signature, results []*tasks.TaskResult) error

SetStateSuccess updates task state to SUCCESS

func (*EagerBackend) TriggerChord

func (b *EagerBackend) TriggerChord(groupUUID string) (bool, error)

TriggerChord flags chord as triggered in the backend storage to make sure chord is never trigerred multiple times. Returns a boolean flag to indicate whether the worker should trigger chord (true) or no if it has been triggered already (false)

type ErrGroupNotFound added in v1.0.10

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

ErrGroupNotFound ...

func NewErrGroupNotFound added in v1.0.10

func NewErrGroupNotFound(groupUUID string) ErrGroupNotFound

NewErrGroupNotFound returns new instance of ErrGroupNotFound

func (ErrGroupNotFound) Error added in v1.0.10

func (e ErrGroupNotFound) Error() string

Error implements error interface

type ErrTasknotFound added in v1.0.10

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

ErrTasknotFound ...

func NewErrTasknotFound added in v1.0.10

func NewErrTasknotFound(taskUUID string) ErrTasknotFound

NewErrTasknotFound returns new instance of ErrTasknotFound

func (ErrTasknotFound) Error added in v1.0.10

func (e ErrTasknotFound) Error() string

Error implements error interface

type Interface

type Interface interface {
	// Group related functions
	InitGroup(groupUUID string, taskUUIDs []string) error
	GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)
	GroupTaskStates(groupUUID string, groupTaskCount int) ([]*tasks.TaskState, error)
	TriggerChord(groupUUID string) (bool, error)

	// Setting / getting task state
	SetStatePending(signature *tasks.Signature) error
	SetStateReceived(signature *tasks.Signature) error
	SetStateStarted(signature *tasks.Signature) error
	SetStateRetry(signature *tasks.Signature) error
	SetStateSuccess(signature *tasks.Signature, results []*tasks.TaskResult) error
	SetStateFailure(signature *tasks.Signature, err string) error
	GetState(taskUUID string) (*tasks.TaskState, error)

	// Purging stored stored tasks states and group meta data
	PurgeState(taskUUID string) error
	PurgeGroupMeta(groupUUID string) error
}

Interface - a common interface for all result backends

func NewAMQPBackend

func NewAMQPBackend(cnf *config.Config) Interface

NewAMQPBackend creates AMQPBackend instance

func NewEagerBackend

func NewEagerBackend() Interface

NewEagerBackend creates EagerBackend instance

func NewMemcacheBackend

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

NewMemcacheBackend creates MemcacheBackend instance

func NewMongodbBackend

func NewMongodbBackend(cnf *config.Config) Interface

NewMongodbBackend creates MongodbBackend instance

func NewRedisBackend

func NewRedisBackend(cnf *config.Config, host, password, socketPath string, db int) Interface

NewRedisBackend creates RedisBackend instance

type MemcacheBackend

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

MemcacheBackend represents a Memcache result backend

func (*MemcacheBackend) GetState

func (b *MemcacheBackend) GetState(taskUUID string) (*tasks.TaskState, error)

GetState returns the latest task state

func (*MemcacheBackend) GroupCompleted

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

GroupCompleted returns true if all tasks in a group finished

func (*MemcacheBackend) GroupTaskStates

func (b *MemcacheBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*tasks.TaskState, error)

GroupTaskStates returns states of all tasks in the group

func (*MemcacheBackend) InitGroup

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

InitGroup creates and saves a group meta data object

func (*MemcacheBackend) PurgeGroupMeta

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

PurgeGroupMeta deletes stored group meta data

func (*MemcacheBackend) PurgeState

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

PurgeState deletes stored task state

func (*MemcacheBackend) SetStateFailure

func (b *MemcacheBackend) SetStateFailure(signature *tasks.Signature, err string) error

SetStateFailure updates task state to FAILURE

func (*MemcacheBackend) SetStatePending

func (b *MemcacheBackend) SetStatePending(signature *tasks.Signature) error

SetStatePending updates task state to PENDING

func (*MemcacheBackend) SetStateReceived

func (b *MemcacheBackend) SetStateReceived(signature *tasks.Signature) error

SetStateReceived updates task state to RECEIVED

func (*MemcacheBackend) SetStateRetry

func (b *MemcacheBackend) SetStateRetry(signature *tasks.Signature) error

SetStateRetry updates task state to RETRY

func (*MemcacheBackend) SetStateStarted

func (b *MemcacheBackend) SetStateStarted(signature *tasks.Signature) error

SetStateStarted updates task state to STARTED

func (*MemcacheBackend) SetStateSuccess

func (b *MemcacheBackend) SetStateSuccess(signature *tasks.Signature, results []*tasks.TaskResult) error

SetStateSuccess updates task state to SUCCESS

func (*MemcacheBackend) TriggerChord

func (b *MemcacheBackend) TriggerChord(groupUUID string) (bool, error)

TriggerChord flags chord as triggered in the backend storage to make sure chord is never trigerred multiple times. Returns a boolean flag to indicate whether the worker should trigger chord (true) or no if it has been triggered already (false)

type MongodbBackend

type MongodbBackend struct {
	Backend
	// contains filtered or unexported fields
}

MongodbBackend represents a MongoDB result backend

func (*MongodbBackend) GetState

func (b *MongodbBackend) GetState(taskUUID string) (*tasks.TaskState, error)

GetState returns the latest task state

func (*MongodbBackend) GroupCompleted

func (b *MongodbBackend) GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)

GroupCompleted returns true if all tasks in a group finished

func (*MongodbBackend) GroupTaskStates

func (b *MongodbBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*tasks.TaskState, error)

GroupTaskStates returns states of all tasks in the group

func (*MongodbBackend) InitGroup

func (b *MongodbBackend) InitGroup(groupUUID string, taskUUIDs []string) error

InitGroup creates and saves a group meta data object

func (*MongodbBackend) PurgeGroupMeta

func (b *MongodbBackend) PurgeGroupMeta(groupUUID string) error

PurgeGroupMeta deletes stored group meta data

func (*MongodbBackend) PurgeState

func (b *MongodbBackend) PurgeState(taskUUID string) error

PurgeState deletes stored task state

func (*MongodbBackend) SetStateFailure

func (b *MongodbBackend) SetStateFailure(signature *tasks.Signature, err string) error

SetStateFailure updates task state to FAILURE

func (*MongodbBackend) SetStatePending

func (b *MongodbBackend) SetStatePending(signature *tasks.Signature) error

SetStatePending updates task state to PENDING

func (*MongodbBackend) SetStateReceived

func (b *MongodbBackend) SetStateReceived(signature *tasks.Signature) error

SetStateReceived updates task state to RECEIVED

func (*MongodbBackend) SetStateRetry

func (b *MongodbBackend) SetStateRetry(signature *tasks.Signature) error

SetStateRetry updates task state to RETRY

func (*MongodbBackend) SetStateStarted

func (b *MongodbBackend) SetStateStarted(signature *tasks.Signature) error

SetStateStarted updates task state to STARTED

func (*MongodbBackend) SetStateSuccess

func (b *MongodbBackend) SetStateSuccess(signature *tasks.Signature, results []*tasks.TaskResult) error

SetStateSuccess updates task state to SUCCESS

func (*MongodbBackend) TriggerChord

func (b *MongodbBackend) TriggerChord(groupUUID string) (bool, error)

TriggerChord flags chord as triggered in the backend storage to make sure chord is never trigerred multiple times. Returns a boolean flag to indicate whether the worker should trigger chord (true) or no if it has been triggered already (false)

type RedisBackend

type RedisBackend struct {
	Backend

	common.RedisConnector
	// contains filtered or unexported fields
}

RedisBackend represents a Memcache result backend

func (*RedisBackend) GetState

func (b *RedisBackend) GetState(taskUUID string) (*tasks.TaskState, error)

GetState returns the latest task state

func (*RedisBackend) GroupCompleted

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

GroupCompleted returns true if all tasks in a group finished

func (*RedisBackend) GroupTaskStates

func (b *RedisBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*tasks.TaskState, error)

GroupTaskStates returns states of all tasks in the group

func (*RedisBackend) InitGroup

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

InitGroup creates and saves a group meta data object

func (*RedisBackend) PurgeGroupMeta

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

PurgeGroupMeta deletes stored group meta data

func (*RedisBackend) PurgeState

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

PurgeState deletes stored task state

func (*RedisBackend) SetStateFailure

func (b *RedisBackend) SetStateFailure(signature *tasks.Signature, err string) error

SetStateFailure updates task state to FAILURE

func (*RedisBackend) SetStatePending

func (b *RedisBackend) SetStatePending(signature *tasks.Signature) error

SetStatePending updates task state to PENDING

func (*RedisBackend) SetStateReceived

func (b *RedisBackend) SetStateReceived(signature *tasks.Signature) error

SetStateReceived updates task state to RECEIVED

func (*RedisBackend) SetStateRetry

func (b *RedisBackend) SetStateRetry(signature *tasks.Signature) error

SetStateRetry updates task state to RETRY

func (*RedisBackend) SetStateStarted

func (b *RedisBackend) SetStateStarted(signature *tasks.Signature) error

SetStateStarted updates task state to STARTED

func (*RedisBackend) SetStateSuccess

func (b *RedisBackend) SetStateSuccess(signature *tasks.Signature, results []*tasks.TaskResult) error

SetStateSuccess updates task state to SUCCESS

func (*RedisBackend) TriggerChord

func (b *RedisBackend) TriggerChord(groupUUID string) (bool, error)

TriggerChord flags chord as triggered in the backend storage to make sure chord is never trigerred multiple times. Returns a boolean flag to indicate whether the worker should trigger chord (true) or no if it has been triggered already (false)

Jump to

Keyboard shortcuts

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