Plugins

The service supports the system of plugins. Plugins must be written in the Python programming language.

Plugin types

There are three sorts of plugins:

  • On event plugin. The plugin is triggered when an event occurs. The plugin should implement a callback function. This function is called on each event of the corresponding type. The set of event types is defined by the service developers.

    Supported event types:

    event type

    description

    monitoring_event

    Event contains monitoring points for sending to a custom monitoring system

    Plugin example:

    This plugin demonstrates the sending of a request monitoring data to another service. All monitoring plugins must implement the BaseRequestMonitoringPlugin abstract class.

  • Background plugin. This sort of plugin is intended for background work.

    The background plugin can implement:

    • custom route

    • background monitoring of service resources

    • collaboration of an event plugin and a background plugin (batching monitoring points)

    • connection to other data sources (Redis, RabbitMQ) and their data processing

    Plugin example:

    This plugin demonstrates background work and implements a route. All background plugins must implement the BaseRequestMonitoringPlugin abstract class.

Matching plugins

Matching plugins intends to speed up matching requests.

Warning

Matching plugins refers only to Luna Python Matcher proxy service.

Enable plugin

If the user implements a plugin, the file with the plugin should be added to the luna_python_matcher/plugins directory of the service. The plugin filename should be added to the LUNA_PYTHON_MATCHER_ACTIVE_PLUGINS/LUNA_MATCHER_PROXY_ACTIVE_PLUGINS configuration setting.

Warning

Every imported from plugin module not abstract class (which realised base plugin class) will be activated. Sometimes a unwary import may lead to import the same class twice. Don’t import plugin modules using top level modules (from plugins.plugin_name.foo import bar, use relative import .foo import bar if possible)

Using plugins with containers

If using containerized application, there are several ways to include the plugins in the container:

  1. Build your own image based on original one. See example Dockerfile below.

  2. Mount plugin files into the container by using –mount flag.

  3. Copy plugin files into the running container, commit changes to the new image (docker commit) and use newly created image.

FROM my-registry/luna-python-matcher:v.0.5.15

COPY --chown=1001:0 my_plugin ./luna_python_matcher/plugins/my_plugin