Elektra  0.8.23
Deferred Plugin Calls

Issue

Calling exported functions is a primary way for coordinating plugins in Elektra. Since some plugins encapsulate other plugins, exported functions from encapsulated plugins become unavailable.

Since encapsulating plugins cannot implement and forward calls for every function exported by encapsulated plugins a generic mechanism for function calls to these encapsulated plugins is needed.

Since some plugins also lazy-load encapsulated plugins the call mechanism is required to be able to defer these calls until the plugins are loaded.

For example when setting I/O bindings with elektraIoSetBinding() the exported function setIoBinding is called for all globally mounted plugins. Since global mounting is implemented using the "list" plugin the exported functions from the plugins are unavailable.

Other examples are the "dini" and "multifile" plugins which use multiple plugins to support different file formats. These plugins also "hide" functions exported by encapsulated plugins.

Constraints

  1. Plugins encapsulating other plugins shall be able to lazy-load them.
  2. Callers shall not be entangled in encapsulating plugin details.
  3. The encapsulation of the plugins shall not be broken.
  4. The mechanism shall be generic.

Assumptions

  1. The called functions do not return a value (e.g. set, open, close, ...)

Considered Alternatives

Decision

Encapsulating plugins export a function called deferredCall with the declaration void ElektraDeferredCall (Plugin * plugin, char * name, KeySet * parameters). Encapsulating plugins shall save multiple deferred calls and call the exported functions specified by name passing the parameters KeySet when a plugin is initialized in the same order as received.

Plugins that support deferred calls shall have the following declaration for their functions void ElektraDeferredCallable (Plugin * plugin, KeySet * parameters). The calling developer is responsible for ensuring that the called functions have a compatible declaration. Encapsulated plugins that do not export a specified function name are omitted.

Argument

The solution allows to change encapsulating plugin implementations without breaking callers.

Implications

The called function receive their parameters via a KeySet.

While called functions could return data using the parameters KeySet (or a seperate KeySet) there is no defined moment when the data can be collected. Defining such a moment would break the lazy-loading constraint. It is recommended to use callbacks passed as parameters. The callback function declaration is not affected by this decision.

Related decisions

Notes

Utility functions that help with managing deferred calls would be nice: