ORIONIS API REFERENCE

THE ORIONIS API

Build with clarity.

Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.

module documentation

Persist delayed jobs and fenced reservations through atomic Lua scripts.

Class RedisQueueDriver Persist delayed jobs and fenced reservations through atomic Lua scripts.
Function _script_digest Return Redis's SHA-1 script identifier (not a security digest).
Constant _CHECK_TYPES Validate key types before any transition can remove persisted queue state.
Constant _CLEAR Remove a queue's complete state and report its previous number of jobs.
Constant _DELETE Remove only a token that still owns an unexpired lease.
Constant _ENCODER Encoder used by redis.
Constant _PUSH Store the envelope and availability together without exposing partial state.
Constant _RELEASE Release only a token that still owns an unexpired lease.
Constant _RESERVATION_FIELDS Reservation fields value used by redis.
Constant _RESERVE Reclaim expired leases and move one due job into an owned reservation.
@lru_cache(maxsize=16)
def _script_digest(script: str) -> str: (source)

Return Redis's SHA-1 script identifier (not a security digest).

Parameters
script:strLua source submitted to Redis.
Returns
strHexadecimal SHA-1 identifier expected by Redis EVALSHA.
_CHECK_TYPES: str = (source)

Validate key types before any transition can remove persisted queue state.

Value
'''
local expected = {\'zset\', \'zset\', \'hash\', \'hash\', \'hash\'}
for index, key in ipairs(KEYS) do
    local actual = redis.call(\'TYPE\', key)[\'ok\']
    if actual ~= \'none\' and actual ~= expected[index] then
        return redis.error_reply(\'Queue key has invalid Redis type\')
    end
...

Remove a queue's complete state and report its previous number of jobs.

Value
'''
local count = redis.call(\'HLEN\', KEYS[3])
redis.call(\'DEL\', unpack(KEYS))
return count
'''

Remove only a token that still owns an unexpired lease.

Value
_CHECK_TYPES + '''
local lease = redis.call(\'ZSCORE\', KEYS[2], ARGV[1])
if redis.call(\'HGET\', KEYS[5], ARGV[1]) ~= ARGV[2]
   or not lease or tonumber(lease) <= tonumber(ARGV[3]) then return 0 end
redis.call(\'ZREM\', KEYS[2], ARGV[1])
redis.call(\'HDEL\', KEYS[3], ARGV[1])
redis.call(\'HDEL\', KEYS[4], ARGV[1])
...
_ENCODER = (source)

Encoder used by redis.

Value
msgspec.json.Encoder()

Store the envelope and availability together without exposing partial state.

Value
_CHECK_TYPES + '''
if redis.call(\'HEXISTS\', KEYS[3], ARGV[1]) == 1 then return 0 end
redis.call(\'HSET\', KEYS[3], ARGV[1], ARGV[2])
redis.call(\'HSET\', KEYS[4], ARGV[1], 0)
redis.call(\'ZADD\', KEYS[1], ARGV[3], ARGV[1])
return 1
'''
_RELEASE = (source)

Release only a token that still owns an unexpired lease.

Value
_CHECK_TYPES + '''
local lease = redis.call(\'ZSCORE\', KEYS[2], ARGV[1])
if redis.call(\'HGET\', KEYS[5], ARGV[1]) ~= ARGV[2]
   or not lease or tonumber(lease) <= tonumber(ARGV[3]) then return 0 end
redis.call(\'ZREM\', KEYS[2], ARGV[1])
redis.call(\'HDEL\', KEYS[5], ARGV[1])
redis.call(\'ZADD\', KEYS[1], ARGV[4], ARGV[1])
...
_RESERVATION_FIELDS: int = (source)

Reservation fields value used by redis.

Value
3
_RESERVE = (source)

Reclaim expired leases and move one due job into an owned reservation.

Value
_CHECK_TYPES + '''
local expired = redis.call(\'ZRANGEBYSCORE\', KEYS[2], \'-inf\', ARGV[1],
                           \'LIMIT\', 0, 100)
local due = redis.call(\'ZRANGEBYSCORE\', KEYS[1], \'-inf\', ARGV[1], \'LIMIT\',↵
 0, 1)
local id = due[1] or expired[1]
if not id then return {} end
...