task

package
v2.0.64 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 5 Imported by: 7

Documentation

Index

Constants

View Source
const (
	DefaultQueue = "default"
)

Variables

This section is empty.

Functions

func CallbackWrapHandler

func CallbackWrapHandler(handler SubTask, callback CallbackFunc) queue.ConsumerFunc

func WrapHandler

func WrapHandler(handler SubTask) queue.ConsumerFunc

Types

type CallbackFunc

type CallbackFunc func(context.Context, interface{}) error

CallbackFunc 消费结果统一回调

type IHandler

type IHandler interface {
	Handle(ctx context.Context, rw io.Writer, msg message.IMessage) error
}

IHandler 任务MQ路由的回调接口/**/

type IService

type IService interface {
	String() string
	Start(ctx context.Context)
}

type IServiceAppend added in v2.0.45

type IServiceAppend interface {
	AppendStart(ctx context.Context, Routers []RabbitMqTask)
}

type MemoryService

type MemoryService interface {
	IService
	AddTasks(task ...MemoryTask) MemoryService
}

type MemorySpec

type MemorySpec struct {
	TaskName   string
	RoutingKey string
}

type MemoryTask

type MemoryTask interface {
	GetSpec() *MemorySpec
	IHandler
}

type NsqService

type NsqService interface {
	IService
	AddTasks(task ...NsqTask) NsqService
}

type NsqSpec

type NsqSpec struct {
	TaskName     string
	RoutingKey   string
	Exchange     string
	ExchangeType string
	QueueName    string
	RoutingMap   map[string]SubTask
	ConsumerNum  int
	CTag         string
}

type NsqTask

type NsqTask interface {
	GetSpec(ctx context.Context) *NsqSpec
	IHandler
}

type RabbitMqService

type RabbitMqService interface {
	IService
	IServiceAppend
	AddTasks(task ...RabbitMqTask) RabbitMqService
}

type RabbitMqSpec

type RabbitMqSpec struct {
	TaskName     string
	Group        string
	Vhost        string
	RoutingKeys  []string
	RoutingKey   string
	Exchange     string
	ExchangeType string
	QueueName    string
	SubTasks     []SubTask
	ConsumerNum  int
	CoroutineNum int
	Prefetch     int
	AutoAck      bool
	Passive      bool // if false, a missing exchange will be created on the server
	Declare      bool
	QueueDeclare bool
	Durable      bool
}

func (*RabbitMqSpec) GetRoutingKeys

func (r *RabbitMqSpec) GetRoutingKeys() []string

func (*RabbitMqSpec) Route

func (r *RabbitMqSpec) Route(routingKey string) (handler SubTask, ifExist bool)

type RabbitMqTask

type RabbitMqTask interface {
	GetSpec(ctx context.Context) *RabbitMqSpec
	IHandler
}

type RocketMqService

type RocketMqService interface {
	IService
	AddTasks(task ...RocketMqTask) RocketMqService
}

type RocketMqSpec

type RocketMqSpec struct {
	TaskName          string
	GroupName         string
	TopicName         string
	SubTasks          []SubTask
	ConsumerNum       int
	MaxReconsumeTimes int32
	AutoCommit        bool
}

func (*RocketMqSpec) Route

func (r *RocketMqSpec) Route(routingKey string) (handler SubTask, ifExist bool)

type RocketMqTask

type RocketMqTask interface {
	GetSpec(ctx context.Context) *RocketMqSpec
	IHandler
}

type RouteTask added in v2.0.42

type RouteTask interface {
	MatchRoute(key string) bool
	Handle(ctx context.Context, msg message.IMessage) (interface{}, error)
}

type SubTask

type SubTask interface {
	RoutingKey() string
	Handle(ctx context.Context, msg message.IMessage) (interface{}, error)
}

type TasksService

type TasksService interface {
	IService
	AddServices(services ...IService) TasksService
}

Jump to

Keyboard shortcuts

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