delay

package module
v0.0.0-...-5f40e5d Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2016 License: MIT Imports: 9 Imported by: 0

README

Delay

Delay is a function scheduling addon to https://github.com/jrallison/go-workers

Mostly inspired by Google AppEngine delay package

Example

examples/main.go:

package main

import (
	"flag"
	"fmt"
	"github.com/wayt/delay"
)

var mode = flag.String("mode", "worker", "Mode: `worker` or `producer`")
var server = flag.String("server", "192.168.99.100:6379", "Redis host")
var database = flag.String("database", "0", "Redis database")
var pool = flag.String("pool", "30", "Redis pool")
var process = flag.String("process", "1", "Worker unique process ID")

var sayHello = delay.Func("hello", func(name string) { fmt.Printf("Hello %s !\n", name) })

func main() {

	flag.Parse()

	delay.Configure(map[string]string{
		// location of redis instance
		"server": *server,
		// instance of the database
		"database": *database,
		// number of connections to keep open with redis
		"pool": *pool,
		// unique process id for this instance of workers (for proper recovery of inprogress jobs on crash)
		"process": *process,
	})

	if *mode == "worker" {
		delay.Worker(10)
	} else {
		sayHello.Delay("Bob")
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(options map[string]string)

func SetQueue

func SetQueue(q string)

func Worker

func Worker(concurrency int, mids ...workers.Action)

Types

type Function

type Function struct {
	Name string
	// contains filtered or unexported fields
}

func Func

func Func(name string, i interface{}) *Function

func (*Function) Delay

func (f *Function) Delay(args ...interface{}) (string, error)

func (*Function) DelayAt

func (f *Function) DelayAt(at time.Time, args ...interface{}) (string, error)

func (*Function) DelayIn

func (f *Function) DelayIn(in time.Duration, args ...interface{}) (string, error)

func (*Function) Interval

func (f *Function) Interval(sec int) *Function

func (*Function) RetryCount

func (f *Function) RetryCount(count int) *Function

type MiddlewareSentry

type MiddlewareSentry struct{}

func (*MiddlewareSentry) Call

func (s *MiddlewareSentry) Call(queue string, message *workers.Msg, next func() error) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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