model

package
v0.0.0-...-3b8996f Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddJob

func AddJob(key string, job Job) error

AddJob 添加Job

func PushToBucket

func PushToBucket(key string, timestamp int64, jobId string) error

PushToBucket 添加JobId到bucket中

func RemoveFromBucket

func RemoveFromBucket(bucket string, jobId string) int64

RemoveFromBucket 从bucket中删除JobId

func RemoveJob

func RemoveJob(key string) error

RemoveJob 删除Job

Types

type BucketItem

type BucketItem struct {
	Timestamp int64
	JobId     string
}

BucketItem bucket中的元素

func GetFromBucket

func GetFromBucket(key string) (*BucketItem, error)

GetFromBucket 从bucket中获取延迟时间最小的JobId

type Job

type Job struct {
	// Job类型
	Topic string `json:"topic" msgpack:"1"`
	// job唯一标识ID,需确保Job ID唯一
	Id string `json:"id" msgpack:"2"`
	// Job需要延迟的时间, unix时间戳,单位:秒
	Delay int64 `json:"delay" msgpack:"3"`
	// Job的内容,供消费者做具体的业务处理,如果是json格式需转义
	Body string `json:"body" msgpack:"4"`
}

Job 使用msgpack序列化后保存到Redis,减少内存占用 Job存储结构:String;key为Job id,value为job元信息

func GetJob

func GetJob(key string) (*Job, error)

GetJob 获取Job

Jump to

Keyboard shortcuts

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