flowbber.loaders.loader

Base class to load Flowbber plugins.

All Flowbber component loaders extend from the PluginLoader class.

Classes

class flowbber.loaders.loader.PluginLoader(component, api_version='1.0')

Plugin loader utility class.

This class allows to load plugins using Python entry points.

Parameters
  • component (str) – Name of the component.
  • base_class (class) – Base class to check against. Any class specified here must comply with the Component.
  • api_version (str) – Version of the API.

Inheritance

Inheritance diagram of PluginLoader

load_plugins(cache=True)

List all available plugins.

This function lists all available plugins by discovering installed plugins registered in the entry point. This can be costly or error prone if a plugin misbehave. Because of this a cache is stored after the first call.

Parameters
cache (bool) – If True return the cached result. If False force reload of all plugins registered for the entry point.
Returns
An ordered dictionary associating the name of the plugin and the class (subclass of flowbber.components.Component) implementing it.
Return type
OrderedDict
classmethod register(key)

Register a plugin locally.

This method is expected to be used as a decorator. It allows to register a plugin locally without having to create a full Python package to use entrypoints.

Usage:

from flowbber.loaders import source
from flowbber.components.source import Source

@source.register('my_source')
class MySource(Source):
    def collect(self):
        return {'my_value': 1000}

Same apply for aggregators and sinks.