backends

package
v2.0.0-...-0175b30 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: MPL-2.0 Imports: 12 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

func IsAMQP(b Interface) bool

IsAMQP returns true if the backend is AMQP

Types

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

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

Backend represents a base backend structure

func New

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 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 NewRedisCeleryBackend

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

NewRedisBackend creates RedisCeleryBackend instance

type RedisCeleryBackend

type RedisCeleryBackend struct {
	Backend

	common.RedisConnector
	// contains filtered or unexported fields
}

RedisCeleryBackend represents a Redis result backend

func (*RedisCeleryBackend) GetState

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

GetState returns the latest task state

func (*RedisCeleryBackend) GroupCompleted

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

GroupCompleted returns true if all tasks in a group finished

func (*RedisCeleryBackend) GroupTaskStates

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

GroupTaskStates returns states of all tasks in the group This should only be called when all the tasks is completed

func (*RedisCeleryBackend) InitGroup

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

InitGroup creates and saves a group meta data object

func (*RedisCeleryBackend) PurgeGroupMeta

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

PurgeGroupMeta deletes stored group meta data

func (*RedisCeleryBackend) PurgeState

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

PurgeState deletes stored task state

func (*RedisCeleryBackend) SetStateFailure

func (b *RedisCeleryBackend) SetStateFailure(signature *tasks.Signature, errr string) error

SetStateFailure updates task state to FAILURE

func (*RedisCeleryBackend) SetStatePending

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

SetStatePending updates task state to PENDING

func (*RedisCeleryBackend) SetStateReceived

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

SetStateReceived updates task state to RECEIVED

func (*RedisCeleryBackend) SetStateRetry

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

SetStateRetry updates task state to RETRY

func (*RedisCeleryBackend) SetStateStarted

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

SetStateStarted updates task state to STARTED

func (*RedisCeleryBackend) SetStateSuccess

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

SetStateSuccess updates task state to SUCCESS

func (*RedisCeleryBackend) TriggerChord

func (b *RedisCeleryBackend) 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