esyncsvc

package
v0.0.0-...-5c89f79 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitTimeWheel

func InitTimeWheel()

初始化

func RegisterHandler

func RegisterHandler(eventType string, handlerSlice []HandlerBase)

注册handler

Types

type EventData

type EventData struct {
	EventType   string
	UniqKey     string
	EventData   string
	EventOption *esyncdao.EventOption
}

事件数据结构

type EventService

type EventService struct{}

func (*EventService) AddEvent

func (svc *EventService) AddEvent(ctx context.Context, eventData *EventData) error

type HandlerBase

type HandlerBase interface {
	GetHandlerID() string // 建议日期加三位数字 比如 210916002
	Do(ctx context.Context, params *HandlerParams) error
}

func GetHandlerList

func GetHandlerList(handlerParams *HandlerParams) []HandlerBase

type HandlerParams

type HandlerParams struct {
	EventID         int64
	EventDefaultDao *esyncdao.EsyncEventDefaultDao
}

func (*HandlerParams) LogIDStr

func (hp *HandlerParams) LogIDStr() string

type Job

type Job func(interface{})

Job 延时任务回调函数

type Task

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

Task 延时任务

type TimeWheel

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

TimeWheel 时间轮

func GetEventTimeWheel

func GetEventTimeWheel() *TimeWheel

func NewTimeWheel

func NewTimeWheel(interval time.Duration, slotNum int, job Job) *TimeWheel

New 创建时间轮

func (*TimeWheel) AddTimer

func (tw *TimeWheel) AddTimer(delay time.Duration, key, data interface{})

AddTimer 添加定时器 key为定时器唯一标识

func (*TimeWheel) RemoveTimer

func (tw *TimeWheel) RemoveTimer(key interface{})

RemoveTimer 删除定时器 key为添加定时器时传递的定时器唯一标识

func (*TimeWheel) Start

func (tw *TimeWheel) Start()

Start 启动时间轮

func (*TimeWheel) Stop

func (tw *TimeWheel) Stop()

Stop 停止时间轮

Jump to

Keyboard shortcuts

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