mongoose.forward.base

class mongoose.forward.base.BaseFormatter[source]

Bases: object

Base class for formatters.

Provides common logic for converting Pydantic models to dictionaries.

static to_dict(data)[source]

Convert the given data into a dictionary.

Handles Pydantic v1/v2 instances and generic objects.

Parameters:

data (Any) – The model instance or data object to convert.

Returns:

A dictionary representation of the data.

Return type:

Dict[str, Any]

class mongoose.forward.base.BaseForwarder(topics)[source]

Bases: object

Base class for all forwarders.

Handles common tasks like subscribing to topics, managing a background worker thread, and the main processing loop.

__init__(topics)[source]

Initialize the BaseForwarder.

Parameters:

topics (List[str]) – List of topic strings to subscribe to.

forward(data)[source]

Process and forward the data.

To be implemented by subclasses.

Parameters:

data (Any) – The data to forward.

start()[source]

Start the forwarder worker thread.

Launches a background daemon thread that subscribes to the configured topics and processes incoming events.