redisdb

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2022 License: MIT Imports: 10 Imported by: 3

README

redisdb-stream

Run Testing codecov Go Report Card

Redis Streams as backend for Queue Package

System Flow

flow

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToStr

func BytesToStr(b []byte) string

BytesToStr converts byte slice to a string without memory allocation. See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .

Note it may break if string and/or slice header will change in the future go versions.

func StrToBytes

func StrToBytes(s string) (b []byte)

StrToBytes converts string to byte slice without a memory allocation.

Types

type Option

type Option func(*options)

Option for queue system

func WithAddr

func WithAddr(addr string) Option

WithAddr setup the addr of redis

func WithBlockTime added in v0.0.3

func WithBlockTime(m time.Duration) Option

WithBlockTime setup the block time for publish messages we use the block command to make sure if no entry is found we wait until an entry is found

func WithCluster

func WithCluster(enable bool) Option

WithCluster redis cluster

func WithConnectionString

func WithConnectionString(connectionString string) Option

WithConnectionString redis connection string

func WithConsumer

func WithConsumer(name string) Option

WithConsumer consumer name

func WithDB

func WithDB(db int) Option

WithPassword redis password

func WithGroup

func WithGroup(name string) Option

WithGroup group name

func WithLogger

func WithLogger(l queue.Logger) Option

WithLogger set custom logger

func WithMaxLength added in v0.0.3

func WithMaxLength(m int64) Option

WithMaxLength setup the max length for publish messages

func WithPassword

func WithPassword(passwd string) Option

WithPassword redis password

func WithRunFunc

func WithRunFunc(fn func(context.Context, core.QueuedMessage) error) Option

WithRunFunc setup the run func of queue

func WithStreamName

func WithStreamName(name string) Option

WithStreamName Stream name

type Worker

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

Worker for Redis

func NewWorker

func NewWorker(opts ...Option) *Worker

NewWorker for struc

func (*Worker) Queue

func (w *Worker) Queue(task core.QueuedMessage) error

Queue send notification to queue

func (*Worker) Request

func (w *Worker) Request() (core.QueuedMessage, error)

Request a new task

func (*Worker) Run

func (w *Worker) Run(task core.QueuedMessage) error

Run start the worker

func (*Worker) Shutdown

func (w *Worker) Shutdown() error

Shutdown worker

Jump to

Keyboard shortcuts

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