Faktory workers for Go
Switch branches/tags
Nothing to show
Clone or download
shinuza and mperham Fixed client code example
Fixed a typo in the job's name
Latest commit de58a75 Jul 1, 2018



This repository provides a Faktory worker process for Go apps. This worker process fetches background jobs from the Faktory server and processes them.

How is this different from all the other Go background worker libraries? They all use Redis or another "dumb" datastore. This library is far simpler because the Faktory server implements most of the data storage, retry logic, Web UI, etc.


You must install Faktory first. Then:

go get -u github.com/contribsys/faktory_worker_go


To process background jobs, follow these steps:

  1. Register your job types and their associated funcs
  2. Set a few optional parameters
  3. Start the processing

To stop the process, send the TERM or INT signal.

import (
  worker "github.com/contribsys/faktory_worker_go"

func someFunc(ctx worker.Context, args ...interface{}) error {
  fmt.Println("Working on job", ctx.Jid())
  return nil

func main() {
  mgr := worker.NewManager()

  // register job types and the function to execute them
  mgr.Register("SomeJob", someFunc)
  //mgr.Register("AnotherJob", anotherFunc)

  // use up to N goroutines to execute jobs
  mgr.Concurrency = 20

  // pull jobs from these queues, in this order of precedence
  mgr.Queues = []string{"critical", "default", "bulk"}

  // Start processing jobs, this method does not return

See test/main.go for a working example.


  • How do I specify the Faktory server location?

By default, it will use localhost:7419 which is sufficient for local development. Use FAKTORY_URL to specify the URL, e.g. tcp://faktory.example.com:12345 or use FAKTORY_PROVIDER to specify the environment variable which does contain the URL: FAKTORY_PROVIDER=FAKTORYTOGO_URL. This level of indirection is useful for SaaSes, Heroku Addons, etc.

  • How do I push new jobs to Faktory?
import (
  faktory "github.com/contribsys/faktory/client"

client, err := faktory.Open()
job := faktory.NewJob("SomeJob", 1, 2, 3)
err = client.Push(job)

See the Faktory client for Go or Ruby. You can implement a Faktory client in any programming langauge. See the wiki for details.


Mike Perham, @mperham


This codebase is licensed via the Mozilla Public License, v2.0. https://choosealicense.com/licenses/mpl-2.0/