worker

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Costume logger for asyqn redis implementing: Debug(args ...interface{}) Info(args ...interface{}) Warn(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{})

Index

Constants

View Source
const (
	QueueCritical = "critical"
	QueueDefault  = "default"
)

queque name

View Source
const TaskSendVerifyEmail = "task:send_verify_email"

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct{}

func NewLogger

func NewLogger() *Logger

NewLogger return new logger with zerolog

func (*Logger) Debug

func (logger *Logger) Debug(args ...interface{})

func (*Logger) Error

func (logger *Logger) Error(args ...interface{})

func (*Logger) Fatal

func (logger *Logger) Fatal(args ...interface{})

func (*Logger) Info

func (logger *Logger) Info(args ...interface{})

func (*Logger) Print

func (logger *Logger) Print(level zerolog.Level, args ...interface{})

func (*Logger) Printf

func (logger *Logger) Printf(ctx context.Context, format string, v ...interface{})

func (*Logger) Warn

func (logger *Logger) Warn(args ...interface{})

type PayloadSendVerifyEmail

type PayloadSendVerifyEmail struct {
	Username string `json:"username"`
}

PayloadSendVerifyEmail struct of data needed for worker to do tas send verify email

type RedisTaskDistributor

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

func (*RedisTaskDistributor) DistributeTaskSendVerifyEmail

func (redisDistributor *RedisTaskDistributor) DistributeTaskSendVerifyEmail(
	ctx context.Context,
	payload *PayloadSendVerifyEmail,
	opts ...asynq.Option,
) error

DistributeTaskSendVerifyEmail to Distribute new task to redis when a user was created

type RedisTaskProcessor

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

func (*RedisTaskProcessor) ProcessTaskSendVerifyEmail

func (processor *RedisTaskProcessor) ProcessTaskSendVerifyEmail(ctx context.Context, task *asynq.Task) error

ProcessTaskSendVerifyEmail - function to process "task:send_verify_email" do sending verify email when new user are created

func (*RedisTaskProcessor) Start

func (processor *RedisTaskProcessor) Start() error

Start - to set some woker and start redis server

type TaskDistributor

type TaskDistributor interface {
	//DistributeTaskSendVerifyEmail to Distribute task to redis when new user was created
	DistributeTaskSendVerifyEmail(
		ctx context.Context,
		payload *PayloadSendVerifyEmail,
		opts ...asynq.Option,
	) error
}

func NewRedisTaskDistributor

func NewRedisTaskDistributor(redisOpt asynq.RedisClientOpt) TaskDistributor

NewRedisTaskDistributor create redis task distributor with given opt

type TaskProcessor

type TaskProcessor interface {
	Start() error
	ProcessTaskSendVerifyEmail(ctx context.Context, task *asynq.Task) error
}

TaskProcessor write your new task processor for each task func

func NewRedisTaskProcessor

func NewRedisTaskProcessor(redisOpt asynq.RedisClientOpt, store db.Store, mailer mail.EmailSender) TaskProcessor

NewRedisTaskProcessor returning redis server processor

Directories

Path Synopsis
Package mockworker is a generated GoMock package.
Package mockworker is a generated GoMock package.

Jump to

Keyboard shortcuts

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