Categorygithub.com/icecube092/redisq
modulepackage
0.1.0
Repository: https://github.com/icecube092/redisq.git
Documentation: pkg.go.dev

# README

Redisq

Redisq is a queue-over-redis that provides simple way to works with queues stored in Redis.

Lib works over redis lib.

Advantages

  • Simple - just launch redis-server on persistent mode
  • Enough persistence
  • Good for periodic poll model
  • No need for mature message broker on simple queue task, use if you already have redis-server
  • Distributed write

Disadvantages

  • No broadcasting
  • No distributed read
  • One transaction per time

Warnings

  • Use noeviction mode of redis-server for persist your data

Requirements

  • Redis-server >= 6.2.0

Installation

go get github.com/go-redis/redis@latest

Features:

  • BeginRead locks queue for reading
  • Push into queue without blocking
  • Scan from queue without removing
  • Commit scanned elements
  • Rollback transaction with moving elements into end of queue
  • Cancel breaks transaction, remains elements in queue

On BeginRead queue locks for read and unlocks after Commit, Rollback, or Cancel.

For generic usage with any type lib provides StringConverter interface

Example

type intStringer int // implements redisq.StringConverter

setter := intStringer(1)

q, _ := redisq.NewSeqQueue(cfg)

q.Push(ctx, setter)

getter := intStringer(0)

q.BeginRead(ctx)
q.Scan(ctx, getter)
q.Commit(ctx)

// getter will be intStringer(1)

See queue_test.go for more examples.

Roadmap

  • Distributed read
  • Queue with priority
  • Non-blocking transactions

Run tests

Warning: tests clear the storage after every test.

  • Set TEST_REDIS_QUEUE_NETWORK and TEST_REDIS_QUEUE_ADDR, or just launch redis-server on localhost:6379
  • Run go test ./...

# Functions

No description provided by the author

# Constants

BlockBeginMode defines waiting while queue unlocks.
ErrBeginMode defines error if queue locked on Queue.BeginRead.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author

# Interfaces

No description provided by the author
No description provided by the author

# Type aliases

BeginMode defines behavior of Queue.BeginRead.