queue

package
v0.0.0-...-89c1cf6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enqueue

func Enqueue(id TaskID, data interface{}) error

Enqueue adds a task to the queue.

func New

func New(rc *redis.Client, isDev bool, ex map[TaskID]TaskExecutor)

New initializes the queue tasks.

func SetAsSubscriber

func SetAsSubscriber()

SetAsSubscriber makes this instance a Pub/Sub subscriber. Each message queued will be processed by this instance.

Types

type Billing

type Billing struct{}

func (*Billing) Run

func (b *Billing) Run(qt QueueTask) error

type Email

type Email struct {
	Send func(p SendEmailParameter) error
}

func (*Email) Run

func (e *Email) Run(qt QueueTask) error

type Emailer

type Emailer interface {
	Send(toEmail, toName, fromEmail, fromName, subject, body, replyTo string) error
}

type QueueTask

type QueueTask struct {
	ID      TaskID      `json:"id"`
	Data    interface{} `json:"data"`
	Created time.Time   `json:"created"`
}

QueueTask represents a queued task.

The Data field contains the necessary data for the task to execute properly.

type SendEmailParameter

type SendEmailParameter struct {
	From    string `json:"From"`
	To      string `json:"To"`
	Subject string `json:"Subject"`
	Body    string `json:"Body"`
}

type TaskExecutor

type TaskExecutor interface {
	Run(t QueueTask) error
}

TaskExecutor is an interface used to execute tasks based on their ID.

type TaskID

type TaskID int

TaskID are IDs representing a specific queued task.

const (
	// TaskEmail is for sending email.
	TaskEmail TaskID = iota
	// TaskCreateInvoice is for creating new Stripe invoice.
	TaskCreateInvoice
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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