tasks

package
v0.0.0-...-6217932 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2016 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

A persistent task queue server.

This is not a very good implementation, but it should be reliable (the state is kept in the database), and it should be able to handle a large number of queued tasks.

Index

Constants

This section is empty.

Variables

View Source
var (
	RemoteError = errors.New("Remote error")
)

Functions

This section is empty.

Types

type StateMachine

type StateMachine struct {
	Client  services.TaskClient
	Plans   map[string]*task_api.Plan
	Actions map[string]task_api.Action
	// contains filtered or unexported fields
}

StateMachine implements a state machine on top of a TaskClient interface (not directly the TaskClient class in this same package).

func NewStateMachine

func NewStateMachine(tc services.TaskClient, plans map[string]*task_api.Plan, actions map[string]task_api.Action) *StateMachine

func (*StateMachine) Run

func (sm *StateMachine) Run(nWorkers int)

type TaskClient

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

func NewTaskClient

func NewTaskClient(addr string, db services.Database) *TaskClient

func NewTaskClientFromConfig

func NewTaskClientFromConfig(db services.Database) *TaskClient

func (*TaskClient) CreateJob

func (t *TaskClient) CreateJob(plan *task_api.Plan, arg string) error

CreateJob creates a new job and puts it in the queue.

func (*TaskClient) GetJob

func (t *TaskClient) GetJob(jobId string) (*task_api.Job, error)

GetJob retrieves a job from persistent storage.

func (*TaskClient) Poll

func (t *TaskClient) Poll(fn func(*task_api.Job))

Poll loops forever, waiting until an event is available, and calling 'fn' with it.

func (*TaskClient) Push

func (t *TaskClient) Push(payload string) error

Push enqueues an event.

func (*TaskClient) PutJob

func (t *TaskClient) PutJob(job *task_api.Job) error

PutJob saves a job to persistent storage.

type TaskServer

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

func NewTaskServer

func NewTaskServer(db services.Database) *TaskServer

func (*TaskServer) Poll

func (ts *TaskServer) Poll(w http.ResponseWriter, r *http.Request)

func (*TaskServer) Push

func (ts *TaskServer) Push(w http.ResponseWriter, r *http.Request)

func (*TaskServer) RegisterService

func (ts *TaskServer) RegisterService()

Directories

Path Synopsis
Re-add orphaned tasks to the task_queue.
Re-add orphaned tasks to the task_queue.

Jump to

Keyboard shortcuts

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