goasynq

package
v1.2.154 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

轻量级队列基于redis

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelClient added in v1.2.108

func DelClient(names ...string)

func DelServer added in v1.2.108

func DelServer(names ...string)

func InitClient

func InitClient(configs ...ClientConfig) error

client

func InitServer

func InitServer(configs ...ServerConfig) error

server

Types

type ClientConfig

type ClientConfig struct {
	goredis.Config
	PoolSize int
	Name     string
}

type GoAsynqClient

type GoAsynqClient struct {
	Client *asynq.Client
}

func DefaultClient

func DefaultClient() *GoAsynqClient

func GetClient

func GetClient(names ...string) *GoAsynqClient

func NewClient

func NewClient(config ClientConfig) *GoAsynqClient

func (*GoAsynqClient) Close

func (c *GoAsynqClient) Close() error

func (*GoAsynqClient) Enqueue

func (c *GoAsynqClient) Enqueue(taskTypeTopic string, payload any, opts ...asynq.Option) (*asynq.TaskInfo, error)

func (*GoAsynqClient) NewTask

func (c *GoAsynqClient) NewTask(taskTypeTopic string, payload any, opts ...asynq.Option) (*asynq.Task, error)

type GoAsynqServer

type GoAsynqServer struct {
	ServeMux *asynq.ServeMux
	Server   *asynq.Server
}

func DefaultServer

func DefaultServer() *GoAsynqServer

func GetServer

func GetServer(names ...string) *GoAsynqServer

func RunServer

func RunServer(config ServerConfig) *GoAsynqServer

func (*GoAsynqServer) Handle

func (s *GoAsynqServer) Handle(taskTypeTopic string, handler asynq.Handler)

func (*GoAsynqServer) HandleFunc

func (s *GoAsynqServer) HandleFunc(taskTypeTopic string, handler func(context.Context, *asynq.Task) error)

func (*GoAsynqServer) Shutdown added in v1.2.136

func (s *GoAsynqServer) Shutdown()

Shutdown会优雅地关闭服务器。 它优雅地关闭了所有活跃的员工。服务器将等待 在配置中指定的持续时间内,主动工作人员完成处理任务。关机超时。 如果worker在超时期间没有完成任务处理,则该任务将被推回Redis。

func (*GoAsynqServer) Stop

func (s *GoAsynqServer) Stop()

Stop指示服务器停止从队列中提取新任务。 在关闭服务器之前,可以使用Stop来确保所有 在服务器关闭之前处理当前活动的任务。

Stop不会关闭服务器,请确保在退出前调用shutdown。

type ServerConfig

type ServerConfig struct {
	Name string
	goredis.Config
	PoolSize    int
	Concurrency int //default 10 指定要使用的并发工作线程数量
	Queues      map[string]int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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