Redis context

Redis is used for publishing processing events. Message is published to chanel ‘luna-sender:{account_id}’ in format msg_to_luna_sender.

class luna_handlers.redis_db.redis_context.BaseRedisContext(channelName='luna-sender', storageTime=None)[source]

Base class for Redis context.

channelName

A string, redis channel prefix

logger

A Logger

storageTime

storage time (“UTC” or “LOCAL”)

abstract async close()[source]

Close connections.

Return type:

None

abstract async initConnections()[source]

Init connections.

Return type:

None

async publish(events, requestId)[source]

Publish events. Msg is published to channel ‘luna-sender:{account_id}’ in format: msg_to_luna_sender

Parameters:
  • events – events

  • requestId – request id

Return type:

None

async publishRawEvent(event, handlerId, requestId)[source]

Publish events. Msg is published to channel ‘luna-sender:{account_id}’ in format: msg_to_luna_sender

Parameters:
  • event – user raw event

  • handlerId – handler id

  • requestId – request id

Return type:

None

class luna_handlers.redis_db.redis_context.RedisContext(host='127.0.0.1', port=6379, password=None, channelName='luna-sender', storageTime=None)[source]

Redis context

connectionsPool

An instance of aioredis.ConnectionsPool

channelName

A string, redis channel prefix

host

redis host

port

redis port

password

redis password

async close()[source]

Close connections pool.

Return type:

None

async initConnections()[source]

Init redis connections pool.

Return type:

None

class luna_handlers.redis_db.redis_context.SentinelRedisContext(sentinels, masterName, redisPassword, channelName='luna-sender', storageTime=None)[source]

Redis context for installations with sentinel.

sentinels

A List of tuples (host, port), addresses of sentinels

sentinel

An instance of Sentinel interface

masterName

A str, name of the redis master set

channelName

A string, redis channel prefix

connectionsPool

A aioredis.sentinel.ManagedPool, pool managed by sentinel

async close()[source]

Close sentinel pool.

Return type:

None

async initConnections()[source]

Init sentinel and managed pool.

Raises:

asyncio.TimeoutError

Return type:

None