func (s *Store) Push(j *Job) (id int, err error) {
	s.Lock()
	j.Status = New
	j.Created.Time = time.Now().UTC()
	j.Created.Valid = true
	tx, err := s.db.Beginx()
	if err != nil {
		goto UNLOCK
	}
	if err = j.Create(tx); err != nil {
		tx.Rollback()
		goto UNLOCK
	}
	id = j.ID
	err = tx.Commit()
UNLOCK:
	s.Unlock()
	return id, err
}
Push inserts a new Job into the queue
package jobs
import (
	"errors"
	"fmt"
	log "github.com/DataDrake/waterlog"
	"github.com/getsolus/ferryd/config"
	"github.com/jmoiron/sqlx"
	"path/filepath"
	"sync"
	"time"
)
var (
	ErrNoJobReady = errors.New("No jobs ready to run")
)
const (
	DB = "jobs.db"
	SQLiteOpts = "?cache=shared"
)
type Store struct {
	sync.Mutex
	db   *sqlx.DB
	next *Job
	stop chan bool
	done chan bool
}
func NewStore() (s *Store, err error) {
	db, err := sqlx.Open("sqlite3", filepath.Join(config.Current.BaseDir, DB)+SQLiteOpts)
	if err != nil {
		return nil, err
	}
	db.SetMaxOpenConns(1)
	db.MustExec(JobSchema)
	s = &Store{
		db:   db,
		next: nil,
		stop: make(chan bool),
		done: make(chan bool),
	}
	err = s.UnclaimRunning()
	return
}
func (s *Store) Close() error {
	if s.db != nil {
		err := s.db.Close()
		s.db = nil
		return err
	}
	return nil
}
func (s *Store) GetJob(id int) (j *Job, err error) {
	j = &Job{}
	err = s.db.Get(&j, getJob, id)
	return
}
func (s *Store) UnclaimRunning() (err error) {
	s.Lock()
	if _, err = s.db.Exec(clearRunningJobs); err != nil {
		err = fmt.Errorf("Failed to unclaim running jobs, reason: '%s'", err.Error())
	}
	s.Unlock()
	return
}