Documentation ¶
Index ¶
- Constants
- type AMQPBackend
- func (amqpBackend *AMQPBackend) GetState(taskUUID string) (*TaskState, error)
- func (amqpBackend *AMQPBackend) GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)
- func (amqpBackend *AMQPBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*TaskState, error)
- func (amqpBackend *AMQPBackend) InitGroup(groupUUID string, taskUUIDs []string) error
- func (amqpBackend *AMQPBackend) PurgeGroupMeta(groupUUID string) error
- func (amqpBackend *AMQPBackend) PurgeState(taskUUID string) error
- func (amqpBackend *AMQPBackend) SetStateFailure(signature *signatures.TaskSignature, err string) error
- func (amqpBackend *AMQPBackend) SetStatePending(signature *signatures.TaskSignature) error
- func (amqpBackend *AMQPBackend) SetStateReceived(signature *signatures.TaskSignature) error
- func (amqpBackend *AMQPBackend) SetStateStarted(signature *signatures.TaskSignature) error
- func (amqpBackend *AMQPBackend) SetStateSuccess(signature *signatures.TaskSignature, result *TaskResult) error
- type AsyncResult
- type Backend
- func NewAMQPBackend(cnf *config.Config) Backend
- func NewEagerBackend() Backend
- func NewMemcacheBackend(cnf *config.Config, servers []string) Backend
- func NewMongodbBackend(conf *config.Config) (Backend, error)
- func NewRedisBackend(cnf *config.Config, host, password, socketPath string, db int) Backend
- type ChainAsyncResult
- type ChordAsyncResult
- type EagerBackend
- func (e *EagerBackend) GetState(taskUUID string) (*TaskState, error)
- func (e *EagerBackend) GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)
- func (e *EagerBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*TaskState, error)
- func (e *EagerBackend) InitGroup(groupUUID string, taskUUIDs []string) error
- func (e *EagerBackend) PurgeGroupMeta(groupUUID string) error
- func (e *EagerBackend) PurgeState(taskUUID string) error
- func (e *EagerBackend) SetStateFailure(signature *signatures.TaskSignature, err string) error
- func (e *EagerBackend) SetStatePending(signature *signatures.TaskSignature) error
- func (e *EagerBackend) SetStateReceived(signature *signatures.TaskSignature) error
- func (e *EagerBackend) SetStateStarted(signature *signatures.TaskSignature) error
- func (e *EagerBackend) SetStateSuccess(signature *signatures.TaskSignature, result *TaskResult) error
- type GroupMeta
- type MemcacheBackend
- func (memcacheBackend *MemcacheBackend) GetState(taskUUID string) (*TaskState, error)
- func (memcacheBackend *MemcacheBackend) GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)
- func (memcacheBackend *MemcacheBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*TaskState, error)
- func (memcacheBackend *MemcacheBackend) InitGroup(groupUUID string, taskUUIDs []string) error
- func (memcacheBackend *MemcacheBackend) PurgeGroupMeta(groupUUID string) error
- func (memcacheBackend *MemcacheBackend) PurgeState(taskUUID string) error
- func (memcacheBackend *MemcacheBackend) SetStateFailure(signature *signatures.TaskSignature, err string) error
- func (memcacheBackend *MemcacheBackend) SetStatePending(signature *signatures.TaskSignature) error
- func (memcacheBackend *MemcacheBackend) SetStateReceived(signature *signatures.TaskSignature) error
- func (memcacheBackend *MemcacheBackend) SetStateStarted(signature *signatures.TaskSignature) error
- func (memcacheBackend *MemcacheBackend) SetStateSuccess(signature *signatures.TaskSignature, result *TaskResult) error
- type MongodbBackend
- func (m *MongodbBackend) GetState(taskUUID string) (*TaskState, error)
- func (m *MongodbBackend) GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)
- func (m *MongodbBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*TaskState, error)
- func (m *MongodbBackend) InitGroup(groupUUID string, taskUUIDs []string) error
- func (m *MongodbBackend) PurgeGroupMeta(groupUUID string) error
- func (m *MongodbBackend) PurgeState(taskUUID string) error
- func (m *MongodbBackend) SetStateFailure(signature *signatures.TaskSignature, err string) error
- func (m *MongodbBackend) SetStatePending(signature *signatures.TaskSignature) error
- func (m *MongodbBackend) SetStateReceived(signature *signatures.TaskSignature) error
- func (m *MongodbBackend) SetStateStarted(signature *signatures.TaskSignature) error
- func (m *MongodbBackend) SetStateSuccess(signature *signatures.TaskSignature, result *TaskResult) error
- type RedisBackend
- func (redisBackend *RedisBackend) GetState(taskUUID string) (*TaskState, error)
- func (redisBackend *RedisBackend) GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)
- func (redisBackend *RedisBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*TaskState, error)
- func (redisBackend *RedisBackend) InitGroup(groupUUID string, taskUUIDs []string) error
- func (redisBackend *RedisBackend) PurgeGroupMeta(groupUUID string) error
- func (redisBackend *RedisBackend) PurgeState(taskUUID string) error
- func (redisBackend *RedisBackend) SetStateFailure(signature *signatures.TaskSignature, err string) error
- func (redisBackend *RedisBackend) SetStatePending(signature *signatures.TaskSignature) error
- func (redisBackend *RedisBackend) SetStateReceived(signature *signatures.TaskSignature) error
- func (redisBackend *RedisBackend) SetStateStarted(signature *signatures.TaskSignature) error
- func (redisBackend *RedisBackend) SetStateSuccess(signature *signatures.TaskSignature, result *TaskResult) error
- type TaskResult
- type TaskState
- func NewFailureTaskState(signature *signatures.TaskSignature, err string) *TaskState
- func NewPendingTaskState(signature *signatures.TaskSignature) *TaskState
- func NewReceivedTaskState(signature *signatures.TaskSignature) *TaskState
- func NewStartedTaskState(signature *signatures.TaskSignature) *TaskState
- func NewSuccessTaskState(signature *signatures.TaskSignature, result *TaskResult) *TaskState
Constants ¶
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
func (*AsyncResult) GetWithTimeout ¶
func (asyncResult *AsyncResult) GetWithTimeout(timeoutD, sleepD time.Duration) (reflect.Value, error)
GetWithTimeout returns task result limited in time(synchronous blocking call)
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 ¶
NewAMQPBackend creates AMQPBackend instance
func NewMemcacheBackend ¶
NewMemcacheBackend creates MemcacheBackend instance
func NewMongodbBackend ¶
NewMongodbBackend creates MongodbBackend 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
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
type EagerBackend ¶
type EagerBackend struct {
// contains filtered or unexported fields
}
EagerBackend represents an "eager" in-memory result backend
func (*EagerBackend) GetState ¶
func (e *EagerBackend) GetState(taskUUID string) (*TaskState, error)
GetState - returns the latest task state
func (*EagerBackend) GroupCompleted ¶
func (e *EagerBackend) GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)
GroupCompleted - returns true if all tasks in a group finished
func (*EagerBackend) GroupTaskStates ¶
func (e *EagerBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*TaskState, error)
GroupTaskStates - returns states of all tasks in the group
func (*EagerBackend) InitGroup ¶
func (e *EagerBackend) InitGroup(groupUUID string, taskUUIDs []string) error
InitGroup - saves UUIDs of all tasks in a group
func (*EagerBackend) PurgeGroupMeta ¶
func (e *EagerBackend) PurgeGroupMeta(groupUUID string) error
PurgeGroupMeta - deletes stored group meta data
func (*EagerBackend) PurgeState ¶
func (e *EagerBackend) PurgeState(taskUUID string) error
PurgeState - deletes stored task state
func (*EagerBackend) SetStateFailure ¶
func (e *EagerBackend) SetStateFailure(signature *signatures.TaskSignature, err string) error
SetStateFailure - sets task state to FAILURE
func (*EagerBackend) SetStatePending ¶
func (e *EagerBackend) SetStatePending(signature *signatures.TaskSignature) error
SetStatePending - sets task state to PENDING
func (*EagerBackend) SetStateReceived ¶
func (e *EagerBackend) SetStateReceived(signature *signatures.TaskSignature) error
SetStateReceived - sets task state to RECEIVED
func (*EagerBackend) SetStateStarted ¶
func (e *EagerBackend) SetStateStarted(signature *signatures.TaskSignature) error
SetStateStarted - sets task state to STARTED
func (*EagerBackend) SetStateSuccess ¶
func (e *EagerBackend) SetStateSuccess(signature *signatures.TaskSignature, result *TaskResult) error
SetStateSuccess - sets task state to SUCCESS
type GroupMeta ¶
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 MongodbBackend ¶
type MongodbBackend struct {
// contains filtered or unexported fields
}
MongodbBackend represents a MongoDB result backend
func (*MongodbBackend) GetState ¶
func (m *MongodbBackend) GetState(taskUUID string) (*TaskState, error)
GetState - returns the latest task state
func (*MongodbBackend) GroupCompleted ¶
func (m *MongodbBackend) GroupCompleted(groupUUID string, groupTaskCount int) (bool, error)
GroupCompleted - returns true if all tasks in a group finished
func (*MongodbBackend) GroupTaskStates ¶
func (m *MongodbBackend) GroupTaskStates(groupUUID string, groupTaskCount int) ([]*TaskState, error)
GroupTaskStates - returns states of all tasks in the group
func (*MongodbBackend) InitGroup ¶
func (m *MongodbBackend) InitGroup(groupUUID string, taskUUIDs []string) error
InitGroup - saves UUIDs of all tasks in a group
func (*MongodbBackend) PurgeGroupMeta ¶
func (m *MongodbBackend) PurgeGroupMeta(groupUUID string) error
PurgeGroupMeta - deletes stored group meta data
func (*MongodbBackend) PurgeState ¶
func (m *MongodbBackend) PurgeState(taskUUID string) error
PurgeState - deletes stored task state
func (*MongodbBackend) SetStateFailure ¶
func (m *MongodbBackend) SetStateFailure(signature *signatures.TaskSignature, err string) error
SetStateFailure - sets task state to FAILURE
func (*MongodbBackend) SetStatePending ¶
func (m *MongodbBackend) SetStatePending(signature *signatures.TaskSignature) error
SetStatePending - sets task state to PENDING
func (*MongodbBackend) SetStateReceived ¶
func (m *MongodbBackend) SetStateReceived(signature *signatures.TaskSignature) error
SetStateReceived - sets task state to RECEIVED
func (*MongodbBackend) SetStateStarted ¶
func (m *MongodbBackend) SetStateStarted(signature *signatures.TaskSignature) error
SetStateStarted - sets task state to STARTED
func (*MongodbBackend) SetStateSuccess ¶
func (m *MongodbBackend) 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 ¶
IsCompleted returns true if state is SUCCESSS or FAILURE, i.e. the task has finished processing and either succeeded or failed.