GitXplorerGitXplorer
b

go-workers

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
7ffc393ae06478b4e532df0bc90f495de4b69eb5

go-module. vendoring. coverage

bbkcsoft committed 5 years ago
Unverified
0ef56017ca7f399488e756609c40fa0f19a7bb12

Merge branch '1-setup-ci' into 'master'

bbkcsoft committed 7 years ago
Unverified
4d979cbc3176298bfbde2f2325e5b117dee69960

Setup CI

bbkcsoft committed 7 years ago
Unverified
5a7870e61ac359086017279c52b9b6d63cc14f54

Make JobFunc public

bbkcsoft committed 7 years ago
Unverified
dbf81d0b75bbe2fd90ef66a07643dd70cb42a88a

Make sure 'Fetcher' doesn't have a lingering job upon exit (#79)

llxfontes committed 7 years ago
Unverified
d60d79dbbfbb83f849d2430013a59152845fa598

add extended stats add more info to README.md (#66)

ggingray committed 8 years ago

README

The README file for this repository.

pipeline status coverage report

GoDoc

GoWorkers

Forked from https://github.com/jrallison/go-workers since it seemed unmaintained.

Sidekiq compatible background workers in golang.

  • reliable queueing for all queues using brpoplpush
  • handles retries
  • support custom middleware
  • customize concurrency per queue
  • responds to Unix signals to safely wait for jobs to finish before exiting.
  • provides stats on what jobs are currently running
  • well tested

Example usage:

package main

import (
	"github.com/jrallison/go-workers"
)

func myJob(message *workers.Msg) {
  // do something with your message
  // message.Jid()
  // message.Args() is a wrapper around go-simplejson (http://godoc.org/github.com/bitly/go-simplejson)
}

type myMiddleware struct{}

func (r *myMiddleware) Call(queue string, message *workers.Msg, next func() bool) (acknowledge bool) {
  // do something before each message is processed
  acknowledge = next()
  // do something after each message is processed
  return
} 

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

  workers.Middleware.Append(&myMiddleware{})

  // pull messages from "myqueue" with concurrency of 10
  workers.Process("myqueue", myJob, 10)

  // pull messages from "myqueue2" with concurrency of 20
  workers.Process("myqueue2", myJob, 20)

  // Add a job to a queue
  workers.Enqueue("myqueue3", "Add", []int{1, 2})

  // Add a job to a queue with retry
  workers.EnqueueWithOptions("myqueue3", "Add", []int{1, 2}, workers.EnqueueOptions{Retry: true})

  // stats will be available at http://localhost:8080/stats
  go workers.StatsServer(8080)

  // Blocks until process is told to exit via unix signal
  workers.Run()
}