redis_mq

package
v0.0.0-...-947c1ad Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

README

simple mq

use redis list implement a simple maessage queue

blog: https://www.cnblogs.com/li-peng/p/12659222.html
demo

simple delay mq

blog: https://www.cnblogs.com/li-peng/p/12697110.html

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

type Consumer = *consumer

func NewSimpleMQConsumer

func NewSimpleMQConsumer(ctx context.Context, redisCmd redis.Cmdable, topicName string, opts ...ConsumerOption) Consumer

type ConsumerOption

type ConsumerOption func(options *ConsumerOptions)

func NewRateLimitPeriod

func NewRateLimitPeriod(d time.Duration) ConsumerOption

func UseBLPop

func UseBLPop(u bool) ConsumerOption

type ConsumerOptions

type ConsumerOptions struct {
	RateLimitPeriod time.Duration
	UseBLPop        bool
}

type Handler

type Handler interface {
	HandleMessage(msg *Message)
}

type Message

type Message struct {
	ID        string `json:"id"`
	Body      []byte `json:"body"`
	Timestamp int64  `json:"timestamp"`
	DelayTime int64  `json:"delayTime"`
	// contains filtered or unexported fields
}

func NewMessage

func NewMessage(id string, body []byte) *Message

type Producer

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

func NewProducer

func NewProducer(cmd redis.Cmdable) *Producer

func (*Producer) Publish

func (p *Producer) Publish(topicName string, body []byte) error

func (*Producer) PublishDelayMsg

func (p *Producer) PublishDelayMsg(topicName string, body []byte, delay time.Duration) error

Jump to

Keyboard shortcuts

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