tasks

package
v0.0.0-...-048bef2 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// queue name
	QueueCritical = "critical"
	QueueDefault  = "default"
	QueueLow      = "low"
)
View Source
const (
	// TypeDispatchPost task name
	TypeDispatchPost = "dispatch:post"
)
View Source
const (
	TypeEmailWelcome = "email:welcome"
)
View Source
const (
	// TypePublishPost task name
	TypePublishPost = "publish:post"
)

Variables

This section is empty.

Functions

func Example

func Example()

func GetClient

func GetClient() *asynq.Client

func HandleDispatchPostTask

func HandleDispatchPostTask(ctx context.Context, t *asynq.Task) error

HandleDispatchPostTask to handle the input task.

func HandleEmailWelcomeTask

func HandleEmailWelcomeTask(ctx context.Context, t *asynq.Task) error

func HandlePublishPostTask

func HandlePublishPostTask(ctx context.Context, t *asynq.Task) error

HandlePublishPostTask to handle the input task.

func NewDispatchPostTask

func NewDispatchPostTask(data DispatchPostPayload) error

NewDispatchPostTask to create a task.

func NewEmailWelcomeTask

func NewEmailWelcomeTask(userID int) (*asynq.Task, error)

func NewPublishPostTask

func NewPublishPostTask(data PublishPostPayload) error

NewPublishPostTask to create a task.

Types

type Config

type Config struct {
	Redis struct {
		Addr         string
		Password     string
		DB           int
		MinIdleConn  int
		DialTimeout  time.Duration
		ReadTimeout  time.Duration
		WriteTimeout time.Duration
		PoolSize     int
		PoolTimeout  time.Duration
		Concurrency  int //并发数
	} `json:"redis"`
}

type DispatchPostPayload

type DispatchPostPayload struct {
	UserID int64 `json:"user_id"`
	PostID int64 `json:"post_id"`
}

DispatchPostPayload define data payload

type EmailWelcomePayload

type EmailWelcomePayload struct {
	UserID int
}

type PublishPostPayload

type PublishPostPayload struct {
	PostID    int64 `json:"post_id"`
	AnchorUID int64 `json:"anchor_uid"`
}

PublishPostPayload define data payload

Jump to

Keyboard shortcuts

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