tasker

package module
v0.0.0-...-f07c8bc Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2016 License: MIT Imports: 8 Imported by: 0

README

tasker

Codeship Status for bsedg/irest Go Report Card

Tasker is a service to manage tasks that can be scheduled.

Development

# build and run the service
docker-compose up -d --force-recreate taskservice

# initialize the database by creating tables, etc.
curl -i -x POST localhost:80/db/init --header "X-Tasker-Authentication: <AUTH_KEY>"

# create a task
curl -i -X POST localhost:80/tasks \
    -d '{"name": "test", "action": "noop", "time": "now"}'

# get all tasks
curl -i localhost:80/tasks
Integration tests

Using the iREST framework to create HTTP integration tests, https://github.com/bsedg/irest, integration tests can be run with the appropriate build tags or with the docker-compose test.

docker-compose -f docker-compose.test.yml -p ci up -d

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(ctx *TaskerContext, th TaskerHandler) http.HandlerFunc

func TasksHandler

func TasksHandler(c *TaskerContext, w http.ResponseWriter, r *http.Request) (interface{}, int, error)

TasksHandler handles management of tasks.

Types

type ErrResponse

type ErrResponse struct {
	Message string `json:"message"`
}

type Task

type Task struct {
	ID            int64     `json:"id"`
	Name          string    `json:"name"`
	Action        string    `json:"action"`
	ScheduledTime string    `json:"time"`
	Created       time.Time `json:"created"`
}

Task encapsulates a named, scheduled task action.

func CreateTask

func CreateTask(name, action, schedTime string) *Task

CreateTask simply creates a task with provided parmaters and generates a psuedo random number.

func (*Task) Valid

func (t *Task) Valid() error

Valid validates input for a task.

type TaskStore

type TaskStore struct {
	DB *sql.DB
}

func (*TaskStore) Delete

func (ts *TaskStore) Delete(id int64)

func (*TaskStore) Get

func (ts *TaskStore) Get(id int64) *Task

func (*TaskStore) GetAll

func (ts *TaskStore) GetAll() ([]*Task, error)

func (*TaskStore) Save

func (ts *TaskStore) Save(t *Task) (*Task, error)

type TaskerContext

type TaskerContext struct {
	Tasks *TaskStore
}

type TaskerHandler

type TaskerHandler func(*TaskerContext, http.ResponseWriter, *http.Request) (interface{}, int, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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