task

package
v1.1.16 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultQueue = "default"
)
View Source
const (
	SrvName = "TaskService"
)

Variables

This section is empty.

Functions

func CallbackWrapHandler

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

func Services added in v0.1.6

func Services() *tService

func WrapHandler

func WrapHandler(handler SubTask) storage.ConsumerFunc

Types

type CallbackFunc

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

CallbackFunc 消费结果统一回调

type Handler

type Handler interface {
	Handle(ctx context.Context, msg storage.Messager) error
}

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

type MemoryService added in v0.1.5

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

type MemorySpec

type MemorySpec struct {
	TaskName   string
	RoutingKey string
}

type MemoryTask

type MemoryTask interface {
	GetSpec() *MemorySpec
	Handler
}

type NsqService added in v0.1.5

type NsqService interface {
	Service
	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
	Handler
}

type RabbitMqService added in v0.1.4

type RabbitMqService interface {
	Service
	AddTasks(task ...RabbitMqTask) RabbitMqService
}

type RabbitMqSpec

type RabbitMqSpec struct {
	TaskName     string
	Vhost        string
	RoutingKeys  []string
	RoutingKey   string
	Exchange     string
	ExchangeType string
	QueueName    string
	SubTasks     []SubTask
	ConsumerNum  int
	CoroutineNum int
	Prefetch     int
	AutoAck      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
	Handler
}

type RocketMqService added in v0.1.5

type RocketMqService interface {
	Service
	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 added in v0.3.7

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

type RocketMqTask

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

type Service

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

type SubTask added in v0.3.7

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

type TasksService added in v0.1.9

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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