wcraas_storage package

Submodules

wcraas_storage.cli module

Console script for wcraas_storage.

wcraas_storage.config module

class wcraas_storage.config.Config[source]

Bases: wcraas_storage.config.Config

classmethod fromenv()[source]

Create a wcraas_storage.Config from Environment Variables.

>>> conf = Config.fromenv()
>>> type(conf)
<class 'config.Config'>
>>> conf._fields
('amqp', 'mongo', 'mapping', 'loglevel')
>>> conf.amqp
AMQPConfig(host='localhost', port=5672, user='guest', password='guest')
>>> conf.mongo
mongo = MongoConfig(host='localhost', port=27017, db='wcraas', user=None, password=None)
>>> conf.mapping
{}
>>> conf.loglevel
20
class wcraas_storage.config.MongoConfig[source]

Bases: wcraas_storage.config.MongoConfig

classmethod fromenv()[source]

Create a wcraas_storage.MongoConfig from Environment Variables.

>>> conf = MongoConfig.fromenv()
>>> type(conf)
<class 'config.MongoConfig'>
>>> conf._fields
('host', 'port', 'db', 'user', 'password')
>>> conf.host
'localhost'
>>> conf.port
27017

wcraas_storage.wcraas_storage module

The WCraaS Storage module is responsible for providing storage services for the platform.

class wcraas_storage.wcraas_storage.StorageWorker(amqp: wcraas_common.config.AMQPConfig, mongo: wcraas_storage.config.MongoConfig, mapping: Dict[str, str], loglevel: int, *args, **kwargs)[source]

Bases: wcraas_common.wcraas_common.WcraasWorker

get_queue_by_collection(collection: str) → str[source]

Return the queue that corresponds to the given collection.

Parameters:collection (string) – The collection with which to determine the queue.
list_collections() → Dict[str, List[Dict[str, str]]][source]

AMQP function that lists available collections in selected MongoDB.

run() → None[source]

Helper function implementing the synchronous boilerplate for initilization and teardown.

start() → None[source]

Asynchronous runtime for the worker, responsible of managing and maintaining async context open.

store(message: aio_pika.message.IncomingMessage) → None[source]

AMQP consumer function, that inserts an IncomingMessage’s json-loaded body in a MongoDB collection based on the source exchange.

Parameters:message (aio_pika.IncomingMessage) – The message that trigered the consume callback.

Module contents

Top-level package for storage.