redistaskmgr

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	QPUSH = redis.NewScript(1, `
local keySet = KEYS[1] .. '::set'
local keyQueue = KEYS[1] .. '::queue'
local id = ARGV[1]
local data = ARGV[2]
local success = redis.call('HSETNX', keySet, id, data)

if (success == 1) then 
	redis.call('RPUSH', keyQueue, id)
end
`)

	QSHIFT = redis.NewScript(1, `
local keySet = KEYS[1] .. '::set'
local keyQueue = KEYS[1] .. '::queue'
local id = redis.call('LPOP', keyQueue)
local data

if (id == nil or id == false) then
	return id
end

data = redis.call('HGET', keySet, id)
redis.call('HDEL', keySet, id)
return data
`)

	QDEL = redis.NewScript(1, `
local keySet = KEYS[1] .. '::set'
local keyQueue = KEYS[1] .. '::queue'

redis.call('DEL', keySet)
redis.call('DEL', keyQueue)
`)

	QREM = redis.NewScript(1, `
local keySet = KEYS[1] .. '::set'
local id = ARGV[1]

redis.call('HDEL', keySet, id)
`)
)

Functions

This section is empty.

Types

type RedisController

type RedisController interface {
	// key prefix
	Prefix(key string) string
	// get redis connect
	Get() redis.Conn
}

type RedisOperator

type RedisOperator struct {
	*redis.Pool
}

func RedisOperatorFromPool

func RedisOperatorFromPool(pool *redis.Pool) *RedisOperator

func (RedisOperator) Prefix

func (RedisOperator) Prefix(key string) string

type RedisTaskMgr

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

func NewRedisTaskMgr

func NewRedisTaskMgr(redisOp RedisController) *RedisTaskMgr

func (*RedisTaskMgr) Destroy

func (mgr *RedisTaskMgr) Destroy(channel string) error

func (*RedisTaskMgr) Exec

func (mgr *RedisTaskMgr) Exec(run func(c redis.Conn) error) error

func (*RedisTaskMgr) Key

func (mgr *RedisTaskMgr) Key(channel string) string

func (*RedisTaskMgr) Push

func (mgr *RedisTaskMgr) Push(channel string, task *mq.Task) error

func (*RedisTaskMgr) Remove

func (mgr *RedisTaskMgr) Remove(channel, id string) error

func (*RedisTaskMgr) Shift

func (mgr *RedisTaskMgr) Shift(channel string) (task *mq.Task, err error)

Jump to

Keyboard shortcuts

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