gwa

package module
v0.0.0-...-afb3b6a Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: MIT Imports: 8 Imported by: 0

README

gocraft/work Adapter for Buffalo

This package implements the github.com/gobuffalo/buffalo/worker.Worker interface using the github.com/gocraft/work package.

Setup

import "github.com/gobuffalo/gocraft-work-adapter"
import "github.com/gomodule/redigo/redis"

// ...

buffalo.New(buffalo.Options{
  // ...
  Worker: gwa.New(gwa.Options{
    Pool: &redis.Pool{
      MaxActive: 5,
      MaxIdle:   5,
      Wait:      true,
      Dial: func() (redis.Conn, error) {
        return redis.Dial("tcp", ":6379")
      },
    },
    Name:           "myapp",
    MaxConcurrency: 25,
  }),
  // ...
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	Enqueur *work.Enqueuer
	Pool    *work.WorkerPool
	Logger  Logger
	// contains filtered or unexported fields
}

Adapter adapts gocraft/work to use with buffalo.

func New

func New(opts Options) *Adapter

New constructs a new adapter.

func (Adapter) Perform

func (q Adapter) Perform(job worker.Job) error

Perform sends a new job to the queue, now.

func (Adapter) PerformAt

func (q Adapter) PerformAt(job worker.Job, t time.Time) error

PerformAt sends a new job to the queue, with a given start time.

func (Adapter) PerformIn

func (q Adapter) PerformIn(job worker.Job, t time.Duration) error

PerformIn sends a new job to the queue, with a given delay.

func (Adapter) PerformU

func (q Adapter) PerformU(job worker.Job) error

Perform sends a new unique job to the queue, now.

func (*Adapter) Register

func (q *Adapter) Register(name string, h worker.Handler) error

Register binds a new job, with a name and a handler.

func (*Adapter) RegisterWithOptions

func (q *Adapter) RegisterWithOptions(name string, opts work.JobOptions, h worker.Handler) error

RegisterWithOptions binds a new job, with a name, options and a handler.

func (*Adapter) Start

func (q *Adapter) Start(ctx context.Context) error

Start starts the adapter event loop.

func (*Adapter) Stop

func (q *Adapter) Stop() error

Stop stops the adapter event loop.

type Logger

type Logger interface {
	Debugf(string, ...interface{})
	Infof(string, ...interface{})
	Errorf(string, ...interface{})
	Debug(...interface{})
	Info(...interface{})
	Error(...interface{})
}

Logger is used by the worker to write logs

type Options

type Options struct {
	*redis.Pool
	Logger         Logger
	Name           string
	MaxConcurrency int
}

Options describes the adapter configuration.

Jump to

Keyboard shortcuts

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