-
Notifications
You must be signed in to change notification settings - Fork 123
Enable/disable hooks. #4499
Comments
My proposal would be to let the user disable every hook, even if it does not appear to make sense right now.
One problem, however, with this approach is that that user would have to manually disable all hooks that are not installed. |
I think a general Only hooks that are enabled by default should use a In addition to enabling/disabling via the KDB, I think a similar option should exist in the
I think we should have an option for the This option could be used to repair most broken KDBs. If the bootstrap backend also breaks only manual file editing can help. Importantly, having such an option allows us to properly return errors from |
I don't think that we should invert the logic. Off on "nothing" is the more robust choice, e.g. on incomplete/missing installations. Instead we should check at installation time which hooks are actually installed and then set
How to change this option if KDB is already broken? I think it is necessary to make kdbOpen/kdbGet as robust as possible, so even on failures regarding hooks we only yield warnings (simply disabling broken hooks).
Why would a missing hook have errors later? |
I'm not a fan of this. The default should be correct and working without needing to execute code after install. Also what is "at installation time"? The script would need to run, every time a new hook plugin is installed. But then, why not just default to "enabled"? If we really want to set
The option is part of the We could create a separate
At the very least, there should be an error, if a hook (e.g.
Well for example, if But that can be fixed, if we still produce errors for hooks explicitly enabled via the contract. Then any application that requires a hook can simply add the option to the contract and I propose this logic:
Alternatively, we use the backend plugin described above and do:
|
Because then all would be enabled, and not the ones which are installed.
Makes sense, but is a far-away feature.
Yes, for contracts there can be an error in kdbOpen.
How you want to do that check? |
I meant default to "enabled" when there is an
Just try to load the plugin (just the module loading without calling the open function). If it works continue, if it fails consider the hook disabled. Since plugin names for hooks are hardcoded this should work. Specifically, instead of just doing elektraPluginFactory factory = elektraModuleLoad (modules, name, errorKey);
if (factory == NULL) {
// plugin not installed -> consider hook disabled
return;
}
Plugin * plugin = elektraPluginOpen (name, modules, config, errorKey); For the special backend plugin I would also just call |
Another idea using a special plugin:
I think this is probably the best solution and the solution that most follows Elektra's principles. It also makes it possible to check whether a hook is installed by doing: kdb get "system:/elektra/hook/<hook name>/installed" |
This is a bad idea as you cannot distinguish something broken vs. missing. For broken at lest a warning must be issued. I've set this low priority, as the general hook framework must be decided first. |
Does it matter in this case? If For informing the user:
If you think something is undecided, please open an issue and concretely list the things where you want clarification. IMO @atmaxinger and I are on the same page and I see the "general framework" as decided. Some details might not be fully worked out, but the details can always change until we have a working implementation that shows any assumptions were correct. |
Of course it matters. There are plenty of different possible errors.
But we should not propagate warnings/errors if everything is as intended (hook not installed). I still don't see any other way as the one I described above (mark at installation what was installed). |
The question is really: Does it matter, if the application did not explicitly request the hook plugin? IMO it doesn't, because if the application/user doesn't request it, it shouldn't matter if the hook is enabled or disabled. However, let's assume it does matter, we actually do want to try to enabled everything that's available.
You could have been more explicit, if you wanted to say this. But only after googling the
My issue is still with the "mark at installation". This seems far too brittle. If it's stored in One option would be do the same thing as Another option would be to create marker files e.g. Finally, a variation of the previous option would be using symlinks instead of empty marker files. So (*) even worse, the script most likely would have to use |
I mark this stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping by writing a message here or create a new issue with the remainder of this issue. |
I closed this now because it has been inactive for more than one year. If I closed it by mistake, please do not hesitate to reopen it or create a new issue with the remainder of this issue. |
@markus2330 has identified the need for a user to manualy enable and/or disable certain hooks. Below are two insightful comments on this topic.
This issue shall serve as a focused place for discussion about how we solve this.
kdb cache
already has support for disabling a global plugin, this feature should be available (in the same way) for all global plugins.Important is that the user can always fix the problem somehow (e.g. disable the broken plugin). If we already fail in kdbOpen, then e.g.
kdb cache disable
probably will also fail, as it tries to write to KDB (and obviously needs to open it first).So I think broken global plugins can only lead to a warning, not to an error.
Originally posted by @markus2330 in #4471 (comment)
What I meant was that there is already a failure case (couldn't load
gopts
plugin), but the function doesn't actually return an error code for that.I agree and disagree... The flag in the KDB doesn't make sense for all hooks. Especially for
gopts
it isn't the right solution.gopts
can only be enabled via thekdbOpen
contract. Therefore having a permanent flag in the KDB makes zero sense. It makes no sense to "enable gopts by default" and if the flag is used to override the contract it will just break applications that expectgopts
to run.For
cache
the flag makes sense of course. Forspec
I could see the flag as well, but in this case it is probably more about switching from errors to warnings. I don't really see a case where completely disablingspec
would help. Finally, there is the notification stuff. AFAIK forinternalnotification
the situation is the same was withgopts
. You enable it only via contract and therefore a flag in the KDB is useless. Fordbus
andzeromq
enabling/disabling via the KDB would probably make sense again.Yes, I'd do that too. But as stated above, I'd tailor the actual config to the individual hook. So for
spec
it might be something likesystem:/elektra/hook/spec/loglevel
.We could also switch from
cache/enabled
tocache/disabled
which automatically switches the default to "cache enabled".Originally posted by @kodebach in #4471 (comment)
The text was updated successfully, but these errors were encountered: