taskmanager

package
v0.0.128 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2015 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//TaskAgentLongRunning --
	TaskAgentLongRunning ProfileType = "agent_task_long_running"
	//TaskAgentScheduledTask --
	TaskAgentScheduledTask ProfileType = "agent_scheduled_task"
	//TaskLeaseProcurement --
	TaskLeaseProcurement ProfileType = "lease_procurement"
	//TaskLeaseReStock --
	TaskLeaseReStock ProfileType = "lease_restock"
	//TaskInventoryLedger --
	TaskInventoryLedger ProfileType = "inventory_ledger"
	//TaskLongPollQueue --
	TaskLongPollQueue ProfileType = "longpoll_queue"
	//TaskChildID -- child task spawned from current task
	TaskChildID = "child_task_id"
	//TaskActionMetaName --
	TaskActionMetaName = "task_action"

	//ExpiredTask -
	ExpiredTask int64 = 0
	//TaskStatusAvailable --- task status is set to available
	TaskStatusAvailable = "available"

	//AgentTaskStatusInitializing ---
	AgentTaskStatusInitializing = "initializing"
	//AgentTaskStatusScheduled ---
	AgentTaskStatusScheduled = "scheduled"
	//AgentTaskStatusRunning ---
	AgentTaskStatusRunning = "running"
	//AgentTaskStatusComplete ---
	AgentTaskStatusComplete = "complete"
	//AgentTaskStatusFailed ---
	AgentTaskStatusFailed = "failed"
)

Variables

View Source
var (
	//ErrNoResults - no results found in query
	ErrNoResults = errors.New("no results found")
	//AgentTaskPollerInterval - time offset to poll a task from an agent
	AgentTaskPollerInterval = time.Duration(2) * time.Second
	//AgentTaskPollerTimeout - time until a agent will expire its task if not polled
	AgentTaskPollerTimeout = time.Duration(5) * time.Minute
)

Functions

This section is empty.

Types

type Agent added in v0.0.94

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

Agent an object which knows how to handle long running tasks. polling, timeouts etc

func NewAgent added in v0.0.95

func NewAgent(t TaskManagerInterface, callerName string) *Agent

NewAgent -- creates a new initialized agent object

func (*Agent) GetStatus added in v0.0.95

func (s *Agent) GetStatus() chan string

GetStatus - returns a status emitting channel

func (*Agent) GetTask added in v0.0.95

func (s *Agent) GetTask() *Task

GetTask - get the agents task object

func (*Agent) Run added in v0.0.94

func (s *Agent) Run(process func(*Agent) error)

Run - this begins the running of an agent's async process

type ProfileType

type ProfileType string

ProfileType - indicator of the purpose of the task to be performed

type RedactedTask added in v0.0.66

type RedactedTask struct {
	ID         bson.ObjectId          `bson:"_id"`
	Timestamp  int64                  `bson:"timestamp"`
	Expires    int64                  `bson:"expires"`
	Status     string                 `bson:"status"`
	Profile    ProfileType            `bson:"profile"`
	CallerName string                 `bson:"caller_name"`
	MetaData   map[string]interface{} `bson:"metadata"`
}

RedactedTask - a task object without sensitive information

type Task

type Task struct {
	ID              bson.ObjectId          `bson:"_id"`
	Timestamp       int64                  `bson:"timestamp"`
	Expires         int64                  `bson:"expires"`
	Status          string                 `bson:"status"`
	Profile         ProfileType            `bson:"profile"`
	CallerName      string                 `bson:"caller_name"`
	MetaData        map[string]interface{} `bson:"metadata"`
	PrivateMetaData map[string]interface{} `bson:"private_metadata"`
	// contains filtered or unexported fields
}

Task - a task object

func (Task) Equal added in v0.0.120

func (s Task) Equal(b Task) bool

Equal - define task equality

func (*Task) GetPrivateMeta added in v0.0.66

func (s *Task) GetPrivateMeta(name string) interface{}

GetPrivateMeta - get a private meta record

func (*Task) GetPublicMeta added in v0.0.66

func (s *Task) GetPublicMeta(name string) interface{}

GetPublicMeta - get a public metadata record

func (*Task) GetRedactedVersion added in v0.0.66

func (s *Task) GetRedactedVersion() RedactedTask

GetRedactedVersion - returns a redacted version of this task, removing private info

func (*Task) Protect added in v0.0.120

func (s *Task) Protect(taskmanager TaskManagerInterface, mutex sync.RWMutex)

Protect -- add mutex and taskmanager protection to task

func (*Task) Read added in v0.0.120

func (s *Task) Read(read func(*Task) interface{}) interface{}

Read -- Safe way to read from a task

func (*Task) SetPrivateMeta added in v0.0.66

func (s *Task) SetPrivateMeta(name string, value interface{})

SetPrivateMeta - set a private meta data record

func (*Task) SetPublicMeta added in v0.0.66

func (s *Task) SetPublicMeta(name string, value interface{})

SetPublicMeta - set a public metadata record

func (Task) String added in v0.0.120

func (s Task) String() string

func (*Task) Update added in v0.0.120

func (s *Task) Update(update func(*Task) interface{}) interface{}

Update -- Safe way to update a task

type TaskManager

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

TaskManager - manages task interactions crud stuff

func NewTaskManager

func NewTaskManager(taskCollection integrations.Collection) (tm *TaskManager)

NewTaskManager - this creates a new task manager object and returns it

func (*TaskManager) FindAndStallTaskForCaller added in v0.0.64

func (s *TaskManager) FindAndStallTaskForCaller(callerName string) (task *Task, err error)

FindAndStallTaskForCaller - find and lock the first matching task, then return it

func (*TaskManager) FindTask

func (s *TaskManager) FindTask(id string) (t *Task, err error)

FindTask - this will find and return a task with a given ID

func (*TaskManager) GarbageCollectExpiredAgents added in v0.0.97

func (s *TaskManager) GarbageCollectExpiredAgents(callerName string) (changeInfo *mgo.ChangeInfo, err error)

GarbageCollectExpiredAgents --

func (*TaskManager) NewTask

func (s *TaskManager) NewTask(callerName string, profile ProfileType, status string) (t *Task)

NewTask - get us a new empty task

func (*TaskManager) SaveTask

func (s *TaskManager) SaveTask(t *Task) (*Task, error)

SaveTask - saves the given task

func (*TaskManager) ScheduleTask added in v0.0.99

func (s *TaskManager) ScheduleTask(t *Task, expireTime time.Time)

ScheduleTask --

func (*TaskManager) SubscribeToSchedule added in v0.0.100

func (s *TaskManager) SubscribeToSchedule(callerName string) (subscription chan *Task)

SubscribeToSchedule - subscribe to a schedule and get a channel to listen on for a task when it hits its scheduled time

type TaskManagerInterface added in v0.0.95

type TaskManagerInterface interface {
	NewTask(callerName string, profile ProfileType, status string) (t *Task)
	FindTask(id string) (t *Task, err error)
	FindAndStallTaskForCaller(callerName string) (task *Task, err error)
	SaveTask(t *Task) (*Task, error)
	ScheduleTask(t *Task, expireTime time.Time)
}

TaskManagerInterface ---

Jump to

Keyboard shortcuts

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