example_worker

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SendExampleTask = "send_{%example%}"
)

Predefined task types.

Variables

This section is empty.

Functions

This section is empty.

Types

type Enqueuer

type Enqueuer struct {
	// contains filtered or unexported fields
}

Enqueuer is a helper struct for enqueuing email tasks.

func NewEnqueuer

func NewEnqueuer(client *asynq.Client, opt ...EnqueuerOption) *Enqueuer

NewEnqueuer creates a new email enqueuer. This function accepts EnqueuerOption to configure the enqueuer. Default values are used if no option is provided. Default values are:

  • queue name: "default"
  • task deadline: 1 minute
  • max retry: 3

func (*Enqueuer) SendExampleEmail

func (e *Enqueuer) SendExampleEmail(ctx context.Context, exampleID, email, role, merchantName string) error

SendExampleEmail enqueues a task to send an example email. This function returns an error if the task could not be enqueued.

type EnqueuerOption

type EnqueuerOption func(*Enqueuer)

EnqueuerOption is a function that configures an enqueuer.

func WithMaxRetry

func WithMaxRetry(n int) EnqueuerOption

WithMaxRetry configures the max retry.

func WithQueueName

func WithQueueName(name string) EnqueuerOption

WithQueueName configures the queue name.

func WithTaskDeadline

func WithTaskDeadline(d time.Duration) EnqueuerOption

WithTaskDeadline configures the task deadline.

type SendExamplePayload

type SendExamplePayload struct {
	ExampleID    string `json:"{%example%}_id"`
	Email        string `json:"email"`
	Role         string `json:"role"`
	MerchantName string `json:"merchant_name"`
}

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

Worker is a task handler for email delivery.

func NewWorker

func NewWorker(mail mailer) *Worker

NewWorker creates a new email task handler.

func (*Worker) Register

func (w *Worker) Register(mux *asynq.ServeMux)

Register registers task handlers for email delivery.

func (*Worker) Schedule

func (w *Worker) Schedule(s *asynq.Scheduler)

Schedule schedules tasks for the worker.

func (*Worker) SendExampleEmail

func (w *Worker) SendExampleEmail(ctx context.Context, t *asynq.Task) error

SendExampleEmail sends an example email.

Jump to

Keyboard shortcuts

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