rque

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2015 License: MIT Imports: 1 Imported by: 0

README

rque

Simple queue built with RethinkDB.

View the docs.

Installation

$ go get github.com/frozzare/go-rque

Example

que, err := rque.New(rque.Config{
	Address:  "localhost:28015",
	Database: "test",
	Table:    "queue",
})

if err != nil {
	log.Fatalf("Failed to create que: %s", err)
}

for job := range que.Jobs() {
	fmt.Printf("Hello %s\n", job.Name)
}

JSON row in the database:

{
    "name": "Fredrik",
    "data": {}
}

License

MIT © Fredrik Forsmo

Documentation

Overview

Example

Example illustrates the use of rque

package main

import (
	"fmt"
	"log"
	"time"

	"github.com/frozzare/go-rque"
)

func main() {
	que, err := rque.New(rque.Config{
		Address:  "localhost:28015",
		Database: "test",
		Table:    "queue",
	})

	if err != nil {
		log.Fatalf("Failed to create que: %s", err)
	}

	go func() {
		time.Sleep(500 * time.Millisecond)
		que.PostJob(rque.Job{
			ID:   "1",
			Name: "World",
		})
		time.Sleep(500 * time.Millisecond)
		que.PostJob(rque.Job{
			ID:   "1",
			Name: "Goodbye",
		})
		time.Sleep(500 * time.Millisecond)
		que.Quit()
	}()

	for job := range que.Jobs() {
		fmt.Printf("Hello %s\n", job.Name)
	}
}
Output:
Hello World
Hello Goodbye

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Address  string
	Database string
	Table    string
}

Config represent the configurations of the queue

type Job

type Job struct {
	ID   string      `gorethink:"id,omitempty" json:"id"`
	Name string      `gorethink:"name" json:"name"`
	Data interface{} `gorethink:"data,omitempty" json:"data"`
}

Job represent a job in the database

type Que added in v1.1.0

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

Que watches a job table

func New added in v1.1.0

func New(config Config) (*Que, error)

New creates a new Que

func (*Que) Jobs added in v1.1.0

func (q *Que) Jobs() <-chan Job

Jobs returns the jobs channel

func (*Que) PostJob added in v1.1.0

func (q *Que) PostJob(job Job) error

PostJob add a job to the queue

func (*Que) Quit added in v1.1.0

func (q *Que) Quit()

Quit stops the que watcher

Jump to

Keyboard shortcuts

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