activejob

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 9 Imported by: 0

README

An extremely simple interface for ActiveJob.

Currently this package support Shoryuken. Sidekiq is not implemented yet, PRs welcome.

Install
go get -u github.com/Honeybee-Health/activejob
Usage
package main

import (
    "github.com/Honeybee-Health/activejob"
)

func main() {
    job := &activejob.Job{
        QueueName: "my_worker_queue",
        JobClass:  "MyHandlerJob",
        Arguments: []interface{}{},
    }

    awsConfig := &aws.Config{Region: aws.String("us-west-2")}
    jobClient := activejob.NewShoryukenWorker(awsConfig)
    jobID, err := jobClient.Enqueue(job)
    if err != nil {
        return err
    }
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxMessageSize = 262144

	MaxMessageSizeExceeded = errors.New("exceeded maximum supported message size for SQS")
)

Functions

This section is empty.

Types

type ActiveJob

type ActiveJob interface {
	Enqueue(job *Job) (string, error)
}

type EnqueueError

type EnqueueError struct {
	JobID string
	Err   error
}

func (*EnqueueError) Error

func (e *EnqueueError) Error() string

type Job

type Job struct {
	JobClass            string            `json:"job_class,omitempty"`
	JobID               string            `json:"job_id,omitempty"`
	ProviderJobID       *string           `json:"provider_job_id,omitempty"`
	QueueName           string            `json:"queue_name,omitempty"`
	Priority            *int              `json:"priority,omitempty"`
	Arguments           interface{}       `json:"arguments,omitempty"`
	Executions          int               `json:"executions,omitempty"`
	ExceptionExecutions map[string]string `json:"exception_executions,omitempty"`
	Locale              string            `json:"locale,omitempty"`
	Timezone            string            `json:"timezone,omitempty"`
	EnqueuedAt          time.Time         `json:"enqueued_at,omitempty"`
	EnqueueError        error             `json:"enqueue_error,omitempty"`
}

type Shoryuken

type Shoryuken struct {
	Client    sqsiface.SQSAPI
	AwsConfig *aws.Config
}

func NewShoryukenWorker

func NewShoryukenWorker(cfgs ...*aws.Config) *Shoryuken

func (*Shoryuken) Enqueue

func (s *Shoryuken) Enqueue(job *Job) (string, error)

Jump to

Keyboard shortcuts

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