|
Elektra 0.8.26
|
Configuration will be in arrays below the keys:
system/elektra/globalplugins
/prerollback
/rollback
/postrollback
/getresolver
/pregetcache
/pregetstorage
/getstorage
/postgetstorage
/postgetcache
/setresolver
/presetstorage
/setstorage
/precommit
/commit
/postcommit
Additionally, below every of these position following subpositions exist:
/init
/deinit
/foreach
With different semantics each:
If a global plugin returns:
So that plugins know in which position they currently are, the name of the position will be written as string in parentkey (not starting with slash to distinguish with file names).
Exception: foreach plugins only get filenames, so to know in which foreach loop you are, you need to add additional once placements to correctly track your state.
Next to positioning information plugins have to state in their contract that they will work as global plugin, i.e. do not need to work on individual config files, when following contract is present:
infos/status global
If you need a global plugin for your application kdbAddGlobalPlugin from libtools can be used. If the global plugin is already present, it should be a NOP. For this functionality #684 is needed.
Use cases:
Some nice features that will be implemented as global plugins.
Transformation keys which are read and transformed to be usable by the application:
[dir/a]
transform=/x
transform/python=...upper()
/lua=..
(actually two plugins are involved: one that fetches transformation keys, the other that executes the transformation code)
simplifies threading and process locking by not having to think about recursive cases.
Now called semlock-plugin.
Run shell code at end of all plugins, e.g. especially doing
git add git commit
The globbing would be more natural (derived from specification). Or even more advanced ways to copy information from specification to the keys, e.g. type inference
Now called spec-plugin.
It should be possible to write plugins which need all file names of all resolver plugins. E.g. journalling, global mmap.
For mmap it could work the following way:
getresolver/after/foreach
is responsible to check if all files resolved are still the same file (and same number of files), and if the mtime of the mmap file is newer than the resolved file. Iff this is the case for every mount point we will (try) to load the mmaped file in:
getresolver/after/once
The loading of the mmap might fail:
If the loading failed, we will continue by returning 1, if the loading was successful we prematurely abort kdbGet by returning 0.
If we continued with kdbGet we want to persist the KeySet for the next kdbGet() with the same parameters using the global hook:
getresolver/after/once
Its useful to have some important global plugins, e.g. locking by default. See #690.
Internal list to be used when no system/elektra/global_mountpoints/ exists.
State diagrams of plugins need to be redrawn to also include global plugin states.