Documentation ¶
Index ¶
- Variables
- func IsAMQP(b Interface) bool
- type AsyncResult
- func (asyncResult *AsyncResult) Get(sleepDuration time.Duration) ([]reflect.Value, error)
- func (asyncResult *AsyncResult) GetState() *tasks.TaskState
- func (asyncResult *AsyncResult) GetWithTimeout(timeoutDuration, sleepDuration time.Duration) ([]reflect.Value, error)
- func (asyncResult *AsyncResult) Touch() ([]reflect.Value, error)
- type Backend
- type ChainAsyncResult
- type ChordAsyncResult
- type Interface
- type RedisCeleryBackend
- func (b *RedisCeleryBackend) GetState(taskUUID string) (*tasks.TaskState, error)
- func (b *RedisCeleryBackend) GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)
- func (b *RedisCeleryBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*tasks.TaskState, error)
- func (b *RedisCeleryBackend) InitGroup(groupUUID string, taskUUIDs []string) error
- func (b *RedisCeleryBackend) PurgeGroupMeta(groupUUID string) error
- func (b *RedisCeleryBackend) PurgeState(taskUUID string) error
- func (b *RedisCeleryBackend) SetStateFailure(signature *tasks.Signature, errr string) error
- func (b *RedisCeleryBackend) SetStatePending(signature *tasks.Signature) error
- func (b *RedisCeleryBackend) SetStateReceived(signature *tasks.Signature) error
- func (b *RedisCeleryBackend) SetStateRetry(signature *tasks.Signature) error
- func (b *RedisCeleryBackend) SetStateStarted(signature *tasks.Signature) error
- func (b *RedisCeleryBackend) SetStateSuccess(signature *tasks.Signature, results []*tasks.TaskResult) error
- func (b *RedisCeleryBackend) TriggerChord(groupUUID string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBackendNotConfigured ... ErrBackendNotConfigured = errors.New("Result backend not configured") // ErrTimeoutReached ... ErrTimeoutReached = errors.New("Timeout reached") )
Functions ¶
Types ¶
type AsyncResult ¶
AsyncResult represents a task result
func NewAsyncResult ¶
func NewAsyncResult(signature *tasks.Signature, backend Interface) *AsyncResult
NewAsyncResult creates AsyncResult instance
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)
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend represents a base backend structure
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) 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) 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
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)