Documentation ¶
Overview ¶
Package db is used for retrieving redis connections, and has helper methods for interacting with the data held within redis
Index ¶
- func AllQueueNames() []string
- func ClaimedKey(queueName string) string
- func ConsumersKey(queueName string) string
- func GetQueueNameFromKey(key string) (string, error)
- func ItemLockKey(queueName, eventID string) string
- func ItemsKey(queueName string) string
- func QueueChannelNameKey(queueName string) string
- func UnclaimedKey(queueName string) string
- type DBer
- type PipePart
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllQueueNames ¶
func AllQueueNames() []string
AllQueueNames returns a list of all currently active queues
func ClaimedKey ¶
ClaimedKey returns the key for the list of claimed (QRPOP'd) eventIDs in a queue
func ConsumersKey ¶
ConsumersKey returns the key for the sorted set of consumer clientIDs QREGISTER'd to consume from a quueue
func GetQueueNameFromKey ¶
GetQueueNameFromKey takes in any of the above keys produced by this package and returns the queue name used to generate the key
func ItemLockKey ¶
ItemLockKey returns the key which is used as a lock when a consumer QRPOPs an event off the unclaimed list. When the lock expires the item is put back in unclaimed if it hasn't been QACK'd already
func QueueChannelNameKey ¶
QueueChannelNameKey returns the name of the pubsub channel used to broadcast events for the given queue
func UnclaimedKey ¶
UnclaimedKey returns the key for the list of unclaimed eventIDs in a queue
Types ¶
type DBer ¶
type DBer interface { // Cmd is a function which will perform the given cmd/args in redis and // returns the resp. It automatically handles using redis cluster, if that // is enabled Cmd(string, ...interface{}) *redis.Resp // Pipe runs a set of commands (given by p) one after the other. It is *not* // guaranteed that all the commands will be run on the same client. If any // commands return an error the pipeline will stop and return that error. // Otherwise the Resp from each command is returned in a slice // // r, err := db.Pipe( // db.PP("SET", "foo", "bar"), // db.PP("GET", "foo"), // ) Pipe(...*PipePart) ([]*redis.Resp, error) // Scan is a function which returns a channel to which keys matching the // given pattern are written to. The channel must be read from until it is // closed, which occurs when there are no more keys or when an error has // occurred (this error will be logged) // // This should not be used in any critical paths Scan(string) <-chan string // Lua performs one of the preloaded Lua scripts that have been built-in. // It's *possible* that the script wasn't loaded in initLuaScripts() for // some strange reason, this tries to handle that case as well. The integer // passed in is the number of keys the command takes in // // Example: // // db.Lua(redisClient, "LREMRPUSH", 2, "foo", "bar", -1, "value") Lua(string, int, ...interface{}) *redis.Resp // GetAddr returns any valid address of a redis instance. Useful for cases // where we want to create redis connections external to this db package GetAddr() (string, error) }
DBer is implemented and used by the rest of okq to interact with whatever backend has been chosen
var Inst DBer
Inst is an instance of DBer which is automatically initialized and which is what should be used by the rest of okq