jobs

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

package jobs contains the jobs that can be used in the river server

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingTestDir is the error for missing test directory
	ErrMissingTestDir = errors.New("missing test directory in email config")
	// ErrMissingToken is the error for missing token
	ErrMissingToken = errors.New("missing resend api token, set token or use dev mode")
)

Functions

This section is empty.

Types

type EmailArgs

type EmailArgs struct {
	// Message is the email message to send
	Message newman.EmailMessage `json:"message"`
}

EmailArgs for the email worker to process the job

func (EmailArgs) Kind

func (EmailArgs) Kind() string

Kind satisfies the river.Job interface

type EmailConfig

type EmailConfig struct {
	// DevMode is a flag to enable dev mode
	DevMode bool `koanf:"devMode" json:"devMode" jsonschema:"description=enable dev mode" default:"true"`
	// TestDir is the directory to use for dev mode
	TestDir string `koanf:"testDir" json:"testDir" jsonschema:"description=the directory to use for dev mode" default:"fixtures/email"`
	// Token is the token to use for the email provider
	Token string `koanf:"token" json:"token" jsonschema:"description=the token to use for the email provider"`
	// FromEmail is the email address to use as the sender
	FromEmail string `` /* 138-byte string literal not displayed */
}

EmailConfig contains the configuration for the email worker

type EmailWorker

type EmailWorker struct {
	river.WorkerDefaults[EmailArgs]

	EmailConfig
}

EmailWorker is a worker to send emails using the resend email provider the config defaults to dev mode, which will write the email to a file using the mock provider a token is required to send emails using the actual resend provider

func (*EmailWorker) Work

func (w *EmailWorker) Work(ctx context.Context, job *river.Job[EmailArgs]) error

Work satisfies the river.Worker interface for the email worker it sends an email using the resend email provider with the provided email message

Jump to

Keyboard shortcuts

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