models

package
v0.0.0-...-42b7ae8 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2016 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Database *bolt.DB

Database bolt database

Functions

func ClearDatabase

func ClearDatabase(dbPath string)

ClearDatabase removes db file and recreates it

func CloseDatabase

func CloseDatabase()

CloseDatabase closes database

func DeleteJobByID

func DeleteJobByID(id int) (err error)

DeleteJobByID deletes job by id

func DeleteProjectByID

func DeleteProjectByID(id int) (err error)

DeleteProjectByID deletes project by id

func OpenDatabase

func OpenDatabase(dbPath string)

OpenDatabase opens database connection to provided file

Types

type Job

type Job struct {
	ID             int               `json:"id,omitempty"`
	ProjectID      int               `json:"project_id,omitempty"`
	Timing         string            `json:"timing"`
	Command        string            `json:"command"`
	Arguments      []string          `json:"arguments"`
	ExpectedResult map[string]string `json:"expected_result"`
}

Job struct that defines a job

func GetJobByID

func GetJobByID(id int) (job Job, err error)

GetJobByID gets single job id from database

func GetJobs

func GetJobs() (jobs []Job, err error)

GetJobs gets all jobs from database

func NewJob

func NewJob() Job

func (Job) Runnable

func (j Job) Runnable() Runnable

Runnable creates a Runnable that contains information about job

func (*Job) SaveJob

func (j *Job) SaveJob() (err error)

SaveJob saves a job to database

type Project

type Project struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

Project struct that defines a project

func GetProjectByID

func GetProjectByID(id int) (project Project, err error)

GetProjectByID gets single project id from database

func GetProjects

func GetProjects() (projects []Project, err error)

GetProjects gets all projects from database

func (*Project) SaveProject

func (p *Project) SaveProject() (err error)

SaveProject saves a project to database

type Runnable

type Runnable struct {
	JobID int
}

Runnable struct that implements scheduler.Schedulable interface Reason using this instead of job itself is that this way we force database reload before running job and job scheduler does not keep all jobs in memory

func (Runnable) CronTime

func (r Runnable) CronTime() string

CronTime returns Timing for a job

func (Runnable) Run

func (r Runnable) Run()

Run handles loadin job by id from database and executing it

Jump to

Keyboard shortcuts

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