$darkmode
Elektra 0.9.14
|
Applications want to ensure that some functionality (hooks) is present in Elektra.
kdbEnsure
(Rejected because it is too flexible and can be called many times. Furthermore, kdbOpen
would build up configurations that get removed afterwards.)KDB * kdbOpen (Key * parent);
int kdbConfigure (KDB * handle, KeySet * contract, Key * parentKey);
KDB * kdbOpenDefault (Key * parent);
The new kdbOpen only does the absolute minimum work, in particular it doesn't set up any global plugins. If you use kdbOpen you must call kdbConfigure otherwise kdbGet will fail. kdbConfigure configures global plugins (basically just a renamed kdbEnsure). Lastly, kdbOpenDefault does more or less what the old kdbOpen does. It sets up the default case and you can call kdbGet immediately. But you cannot call kdbConfigure after kdbOpenDefault. Rejected because of API bloat and introduction of further state in kdb
.Integrate kdbEnsure
in kdbOpen(Key *errorKey, KeySet *contract)
but only allow hooks.
elektraNotificationOpen
will be renamed and only return a contract KeySet:
The same for gopts:
Finally, we create KDB
with the contracts we got before:
Opening KDB
will fail if any of the contracts cannot be ensured.
As the contract
gets copied, at any point after kdbOpen
the contract can be safely deleted:
The cleanup of the global plugins happens within:
It is safe to use the contract KeySet
also for kdbGet
and kdbSet
invocations. Contract KeySet
s only contain Key
s below system:/elektra/contract
. Therefore, normal KeySet
s should not interfere.