The zaqar.storage.redis.messages module

class MessageController(*args, **kwargs)

Bases: zaqar.storage.base.Message, zaqar.storage.redis.scripting.Mixin

Implements message resource operations using Redis.

Messages are scoped by project + queue.

Redis Data Structures:

  1. Message id’s list (Redis sorted set)

    Each queue in the system has a set of message ids currently in the queue. The list is sorted based on a ranking which is incremented atomically using the counter(MESSAGE_RANK_COUNTER_SUFFIX) also stored in the database for every queue.

    Key: <project_id>.<queue_name>.messages

  2. Index of message ID lists (Redis sorted set)

    This is a sorted set that facilitates discovery of all the message ID lists. This is necessary when performing garbage collection on the IDs contained within these lists.

    Key: msgset_index

  3. Messages(Redis Hash):

    Scoped by the UUID of the message, the redis datastructure has the following information.

    Name Field
    id id
    ttl t
    expires e
    body b
    claim c
    claim expiry time c.e
    client uuid u
    created time cr
  4. Messages rank counter (Redis Hash):

    Key: <project_id>.<queue_name>.rank_counter

bulk_delete(*args, **kwargs)
bulk_get(*args, **kwargs)
delete(*args, **kwargs)
first(*args, **kwargs)
gc(*args, **kwargs)

Garbage-collect expired message data.

Not all message data can be automatically expired. This method cleans up the remainder.

Returns:Number of messages removed
get(*args, **kwargs)
list(*args, **kwargs)
pop(*args, **kwargs)
post(*args, **kwargs)
script_names = ['index_messages']
class MessageQueueHandler(driver, control_driver)

Bases: object

create(*args, **kwargs)
delete(*args, **kwargs)
stats(*args, **kwargs)

Previous topic

The zaqar.storage.redis.driver module

Next topic

The zaqar.storage.redis.models module

Project Source

This Page