scheduler

package module
v0.0.0-...-95f421b Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

README

go-scheduler - A simple scheduler in Go

wercker status

Overview

go-scheduler is a small library that manages goroutines allowing for execution pools, management of jobs, etc.

Installation

Make sure you have a working Go environment. The core library does not have any external dependencies. To run the unit tests, however, the testify library is required.

To install, run:

go get github.com/dakiva/go-scheduler

Collaboration

This library is still early in development. This is a great time to provide suggestions, ideas. Pull requests are welcome.

About

This library is written by Daniel Akiva (dakiva) and is licensed under the apache-2.0 license.

Documentation

Index

Constants

View Source
const (
	SCHEDULED_STATUS = "scheduled"
	RUNNING_STATUS   = "running"
	COMPLETED_STATUS = "completed"
	FAILED_STATUS    = "failed"
)
View Source
const (
	DefaultNumExecutors = 5
)

Variables

View Source
var JobNotFound error = errors.New("Job not found")

Functions

func DefaultExecutor

func DefaultExecutor(jobChan <-chan Job, jobStatusChan chan<- Job)

Types

type Executor

type Executor func(jobChan <-chan Job, jobStatusChan chan<- Job)

type InMemoryJobRepository

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

func NewInMemoryJobRepository

func NewInMemoryJobRepository() *InMemoryJobRepository

func (*InMemoryJobRepository) Load

func (i *InMemoryJobRepository) Load(jobID string) (Job, error)

func (*InMemoryJobRepository) Save

func (i *InMemoryJobRepository) Save(job Job) error

type Job

type Job struct {
	ID          string
	Status      string
	ScheduledOn time.Time
	StartedOn   *time.Time
	CompletedOn *time.Time
	Task        *Task
	RunErr      error
}

func NewJob

func NewJob(task *Task, scheduledOn time.Time) Job

func (Job) Complete

func (j Job) Complete() Job

func (Job) Fail

func (j Job) Fail(err error) Job

func (Job) Start

func (j Job) Start() Job

func (Job) Valid

func (j Job) Valid() bool

type JobRepository

type JobRepository interface {
	Save(job Job) error
	Load(jobID string) (Job, error)
}

type Scheduler

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

func NewCustomScheduler

func NewCustomScheduler(numExecutors int, repository JobRepository, executorStrategy Executor) *Scheduler

func NewScheduler

func NewScheduler() *Scheduler

func (*Scheduler) Destroy

func (s *Scheduler) Destroy()

func (*Scheduler) JobStatus

func (s *Scheduler) JobStatus(jobID string) (Job, error)

func (*Scheduler) Schedule

func (s *Scheduler) Schedule(task *Task, scheduledOn time.Time) (Job, error)

func (*Scheduler) ScheduleNow

func (s *Scheduler) ScheduleNow(task *Task) (Job, error)

type Task

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

func NewTask

func NewTask(name string, f interface{}, params []interface{}) (*Task, error)

func (*Task) Execute

func (t *Task) Execute() error

func (*Task) Name

func (t *Task) Name() string

Directories

Path Synopsis
present

Jump to

Keyboard shortcuts

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