func (w *Worker) processJob(j *jobs.Job) {
	j.Message.String = j.Describe()
	if err := w.executeJob(j); err != nil {
		j.Status = jobs.Failed
		j.Message.String = err.Error()
		j.Message.Valid = true
		log.Errorf("Job '%d' failed with error: '%s'\n", j.ID, err.Error())
		return
	}
	j.Status = jobs.Completed
	log.Infof("Job '%d' completed successfully\n", j.ID)
}
processJob will actually examine the given job and figure out how
to execute it. Each Worker can only execute a single job at a time
package manager
import (
	"errors"
	log "github.com/DataDrake/waterlog"
	"github.com/getsolus/ferryd/jobs"
	"math/rand"
	"time"
)
const MinWait = time.Second * 2
const MaxJitter int64 = 512
type Worker struct {
	timer   *time.Timer
	manager *Manager
	stop    chan bool
	done    chan bool
}
func NewWorker(manager *Manager) *Worker {
	if manager == nil {
		panic("Constructed a Worker without a valid Manager!")
	}
	return &Worker{
		timer:   nil,  
		manager: manager,
		stop:    make(chan bool),
		done:    make(chan bool),
	}
}
func (w *Worker) Stop() {
	if w.timer == nil {
		return
	}
	w.stop <- true
	w.timer.Stop()
	<-w.done
}
func (w *Worker) Start() {
	w.setTime()
	for {
		select {
		case <-w.stop:
			w.done <- true
			return
		case <-w.timer.C:
			job, err := w.manager.store.Claim()
			if err != nil {
				if err != jobs.ErrNoJobReady {
					log.Errorf("Failed to grab a work queue item, reason: '%s'\n", err.Error())
				}
				w.setTime()
				continue
			}
			w.processJob(job)
			err = w.manager.store.Retire(job)
			if err != nil {
				log.Errorf("Error in retiring job '%v' of type '%v', reason: '%s'\n", job.ID, job.Type, err.Error())
			}
			w.setTime()
		}
	}
}
func (w *Worker) setTime() {
	delay := MinWait + (time.Millisecond * time.Duration(rand.Int63n(MaxJitter)))
	if w.timer == nil {
		w.timer = time.NewTimer(delay)
	} else {
		w.timer.Reset(delay)
	}
}