Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBRepository ¶
type DBRepository struct {
// contains filtered or unexported fields
}
DBRepository defines a MySQL-based repository
func (*DBRepository) AddJob ¶
func (r *DBRepository) AddJob(job *Job) (*Job, error)
AddJob adds a job to the queue
func (*DBRepository) Process ¶
func (r *DBRepository) Process(queue string, interval time.Duration, processors map[string]JobProcessor)
Process starts processing jobs from the given queue with the given interval
func (*DBRepository) Setup ¶
func (r *DBRepository) Setup()
Setup is used to perform the setup of the repository
type Job ¶
type Job struct {
ID int64 `db:"id"`
Queue string `db:"queue"`
State string `db:"state"`
Error string `db:"error"`
Payload string `db:"payload"`
CreatedOn int64 `db:"created_on"`
StartedOn int64 `db:"started_on"`
FinishedOn int64 `db:"finished_on"`
}
Job defines a job which can be queued
func NewJob ¶
func NewJob(queue string, payload JobPayload) (*Job, error)
NewJob returns a new job for the given queue with an optional payload
type JobPayload ¶
type JobPayload map[string]interface{}
JobPayload is used to define the payload of a job
type JobProcessor ¶
JobProcessor defines the interface for a job processor
type JobRepository ¶
type JobRepository interface {
Setup()
AddJob(job *Job) (*Job, error)
Process(queue string, interval time.Duration, processors map[string]JobProcessor)
}
JobRepository is the interface to which repositories should conform
func DefaultRepository ¶
func DefaultRepository() (JobRepository, error)
DefaultRepository returns the default repository based on the env variables
func NewMySQLRepository ¶
func NewMySQLRepository(db *sqlx.DB, tableName string) JobRepository
NewMySQLRepository returns a new MySQL-based repository
Source Files
¶
Click to show internal directories.
Click to hide internal directories.