Statscache plugins

How the plugins work is that whenever there is a message for them, their process message is called with the message as the argument. The job of the method is just to store the message in an internal queue.

Now, after some interval, the update method of the plugins is called (by statscache). The job of the update method is to flush the messages to the db using sqlalchemy ORM.

How statscache loads its plugin’s is pretty cool too. So, the entry point is:


    entry_points={
        'statscache.plugin': [
            "volume = statscache_plugins.volume.simple:plugins",
            "releng = statscache_plugins.releng:Plugin",
            #"volume_by_topic = statscache_plugins.volume.by_topic:plugins",
            "volume_by_category = statscache_plugins.volume.by_category:plugins",
            #"volume_by_user = statscache_plugins.volume.by_user:plugins",
            #"volume_by_package = statscache_plugins.volume.by_package:plugins",
            "pagure = statscache_plugins.pagure.pagure_contribution:plugins",
            "pagure_users = statscache_plugins.pagure.pagure_users_contribution:plugins",
            "pagure_project = statscache_plugins.pagure.pagure_project_contribution:plugins",
        ]
    }

This :top: is in statscache_pluins.setup. Statscache just iterates thru these fellas and loads them each as a plugin.

  1. volume
    • this just goes to the simple.py and loads the plugin variable there.
    • volume has VolumePluginMixin defined in utils.py which stores the common logic of initialization and update
    • we have each plugin which extends this mixin and adds the process method.
    • now, we use the plugin_factory method (from utils again) which creates the object and assigns to plugins variable which is read here
  2. releng
    • in releng.init we have a plugin, which is just a front for a collection of many plugins.
    • it has a self._plugins which is basically all the plugins related to releng. They individually are all full fledged plugins.
    • this umbrella plugin just iterates thru the self._plugins and calls the process message (on a new message) and calls the update message to flush the individual queues.

3.pagure

  • here, the exact same model as volume.
  • we have PagurePluginMixin which defines update and init. All the individual plugins extend this with their own process.