worker

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() int64
}

Clock represents a clock to be used by the worker

type RealClock

type RealClock struct{}

RealClock uses the machine clock to return time

func (*RealClock) Now

func (r *RealClock) Now() int64

Now returns time.Now()

type Worker

type Worker struct {
	Debug             bool
	Queue             string
	Logger            zap.Logger
	MaxAttempts       int
	Client            *redis.Client
	BlockTimeout      time.Duration
	SentryURL         string
	BackoffIntervalMs int64
	Clock             Clock
}

Worker is a worker implementation that keeps processing webhooks

func New

func New(
	queue string, redisHost string, redisPort int, redisPassword string, redisDB int,
	maxAttempts int, logger zap.Logger, debug bool, blockTimeout time.Duration,
	sentryURL string, backoffIntervalMs int64, clock Clock,
) *Worker

New creates a new worker instance

func NewDefault

func NewDefault(redisHost string, redisPort int, redisPassword string, redisDB int, logger zap.Logger) *Worker

NewDefault returns a new worker with default options

func (*Worker) DoRequest

func (w *Worker) DoRequest(method, url, payload string) (int, string, error)

DoRequest to some webhook endpoint

func (*Worker) Handle

func (w *Worker) Handle(msg map[string]interface{}) error

Handle a single message from Queue

func (*Worker) ProcessSubscription

func (w *Worker) ProcessSubscription() error

ProcessSubscription to messages from Queue

func (*Worker) Start

func (w *Worker) Start()

Start a new worker with the given params

Jump to

Keyboard shortcuts

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