goq

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2015 License: MIT Imports: 5 Imported by: 0

README

goq

A very simple persistent queue engine utilizing Redis for Go.

Dependencies
  • go get gopkg.in/redis.v3

Documentation

Index

Constants

View Source
const (
	JOB_STATUS_PREFIX = "goq:queue:job:status:"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionOptions

type ConnectionOptions struct {
	Addr         string
	Password     string
	DB           int64
	MaxRetries   int
	DialTimeout  time.Duration
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	PoolSize     int
	PoolTimeout  time.Duration
	IdleTimeout  time.Duration
}

type ErrorHandler

type ErrorHandler func(error)

Function signature for error handler

type Job

type Job struct {
	ID     string
	JSON   string
	Status *Status
}

func (*Job) GetStatus

func (j *Job) GetStatus() error

Method to update this job Status from redis

func (*Job) SetStatus

func (j *Job) SetStatus(code, progress uint8) error

Method to set this job Status locally and to redis

type Options

type Options struct {
	Connection   *ConnectionOptions
	Concurrency  uint8
	QueueName    string
	Processor    Processor
	ErrorHandler ErrorHandler
}

type Processor

type Processor func(*Job)

Function signature for job processor

type Queue

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

func New

func New(opt *Options) *Queue

Function to create new Queue struct

func (*Queue) Enqueue

func (q *Queue) Enqueue(jobJSON string) (string, error)

Method to enqueue job to queue, returns job id

func (*Queue) QueueStatus

func (q *Queue) QueueStatus() (*QueueStatus, error)

Method to get status of this queue

func (*Queue) Run

func (q *Queue) Run()

Method to run the queue worker

type QueueStatus

type QueueStatus struct {
	QueueLength int64
}

type Status

type Status struct {
	Code     uint8
	Progress uint8
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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