resque

package module
v0.0.0-...-3529cb8 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: ISC Imports: 4 Imported by: 1

README

go-resque

GoDoc

Simple Resque queue client for Go.

Installation

go get github.com/everalbum/go-resque

Usage

For example, a simple Resque job being processed by a Ruby worker somewhere:

module Demo
  class Job
    def self.perform(param=nil)
      puts "Processed a job! Param: #{param.inspect}"
    end
  end
end

Enqueue this job from Go:

package main

import (
  "github.com/everalbum/go-resque"
  "github.com/garyburd/redigo/redis"
)

func main() {
  conn, err := redis.Dial("tcp", "127.0.0.1:6379") // Create new Redis client to use for enqueuing

  if err != nil {
    // Handle error
  }

  defer conn.Close()

  // Enqueue the job into the "email" queue with appropriate client
  resque.Enqueue(conn, "email", "Demo::Job")

  // Enqueue into the "default" queue with passing one parameter to the Demo::Job.perform
  resque.Enqueue(conn, "default", "Demo::Job", 1)

  // Enqueue into the "default" queue with passing multiple
  // parameters to Demo::Job.perform so it will fail
  resque.Enqueue(conn, "default", "Demo::Job", 1, 2, "woot")
}

This also works with resque-scheduler. You can enqueue jobs using EnqueueIn or EnqueueAt to enqueue a job in the future.

  // Enqueues this job 60 seconds from now.
  delay := time.Duration(60) * time.Second
  resque.EnqueueIn(conn, delay, "default", "Demo::Job", 1, 2, "woot")
  
  // Enqueues this job at a specific time
  t := time.Now().Add(delay)
  resque.EnqueueAt(conn, t, "default", "Demo::Job", 1, 2, "woot")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enqueue

func Enqueue(client redis.Conn, queue, jobClass string, args ...interface{}) (int64, error)

func EnqueueAt

func EnqueueAt(client redis.Conn, t time.Time, queue, jobClass string, args ...interface{}) error

func EnqueueIn

func EnqueueIn(client redis.Conn, delay time.Duration, queue, jobClass string, args ...interface{}) error

func Failure

func Failure(client redis.Conn, queue, jobClass string, args ...interface{}) (int64, error)

func Size

func Size(client redis.Conn, queue string) (int64, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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