Connector Plugins


The last plugin class is the Connector plugin. This plugin class allows for the saving or passing off of the final result. Once all other plugins have completed their tasks, the final result is sent to the loaded connector plugins for handling. For example, a connector plugin may save results to disk, ElasticSearch, or even pass them off to a queueing system such as RabbitMQ.

Connector plugins can be defined multiple ways. In these examples, we will use the filedir connector plugin, allowing results to be saved to disk.

From stoq.cfg:

connectors = filedir


Multiple plugins can be defined separated by a comma.

From the command line:

$ stoq run -C filedir [...]


Multiple plugins can be defined by simply adding the plugin name

Or, when instantiating the Stoq() class:

>>> import stoq
>>> connectors = ['filedir']
>>> s = Stoq(connectors=connectors, [...])

Writing a plugin

A connector plugin must be a subclass of the ConnectorPlugin class.

As with any plugin, a configuration file must also exist and be properly configured.


from stoq.data_classes import StoqResponse
from stoq.plugins import ConnectorPlugin

class ExampleConnector(ConnectorPlugin):
    def save(self, response: StoqResponse) -> None:
        with open('/tmp/stoqresult.txt', 'w') as result:


class stoq.plugins.connector.ConnectorPlugin(config, plugin_opts)[source]
Return type:None