-
Notifications
You must be signed in to change notification settings - Fork 123
Conversation
@markus2330 please review my PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, looks very nice. Maybe the names are not ideal?
And please add some more documentation (within src/plugins/doc/doc.h)
src/include/kdbprivate.h
Outdated
@@ -323,6 +323,11 @@ struct _KDB | |||
|
|||
Plugin * notificationPlugin; /*!< reference to global plugin for notifications.*/ | |||
ElektraNotificationCallbackContext * notificationCallbackContext; /*!< reference to context for notification callbacks.*/ | |||
|
|||
KeySet * global; /*!< This keyset can be used by global plugins to pass data through |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need it here if it is actually only a local variable within kdbGet/kdbSet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was to have ksNew() only once per kdbOpen() and then ksClear() it before return such that plugins do not have to think about cleaning up.
As discussed in a meeting, part of it would be persisted in the cache, but this is for a different PR.
src/include/kdbplugin.h
Outdated
@@ -108,7 +108,8 @@ Plugin * elektraPluginExport (const char * pluginName, ...); | |||
KeySet * elektraPluginGetConfig (Plugin * handle); | |||
void elektraPluginSetData (Plugin * plugin, void * handle); | |||
void * elektraPluginGetData (Plugin * plugin); | |||
|
|||
void elektraPluginSetGlobal (Plugin * plugin, KeySet * ks); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a correct name? If it is only available via a single invocation it is not exactly global, is it?
Maybe elektraPluginSetSharedData?
(And elektraPluginSetGlobalData for actually globally available data within a KDB handle?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this could be misleading terminology. Maybe I can come up with something better.
For my usecase, I only need what I described in doc/decisions/global_plugins.md
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe elektraPluginGetGlobalDataOfCurrentInvocation fits better? (and elektraPluginGetGlobalData if it is really global)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about what makes sense and reworked it to be global within a KDB handle and called it elektraPluginGetGlobalKeySet
.
I am done with the changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, very nice!
get a handle to a global keyset. The global keyset is tied to a KDB handle, initialized on kdbOpen() and | ||
deleted on kdbClose(). | ||
|
||
The resolver plugin is an exception and also gets a handle to the global keyset. This way it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not every plugin?
@@ -127,7 +127,7 @@ compiled against an older 0.8 version of Elektra will continue to work | |||
|
|||
### Core | |||
|
|||
- <<TODO>> | |||
- Global plugins now get a handle to a global keyset, which makes communication between global plugins easier. *(Mihael Pranjić)* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
", for communication between plugins"?
@@ -413,6 +416,11 @@ struct _Plugin | |||
|
|||
void * data; /*!< This handle can be used for a plugin to store | |||
any data its want to. */ | |||
|
|||
KeySet * global; /*!< This keyset can be used by global plugins and the resolver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why special handling of resolver?
/** | ||
* @brief Get a pointer to the global keyset. | ||
* | ||
* Only initialized for global plugins and the resolver. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
* Plugins using this keyset are responsible for cleaning up | ||
* their parts of the keyset which they do not need any more. | ||
* | ||
* If kdbOpen() was not called earlier, NULL will be returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this happen?
@@ -102,6 +102,20 @@ | |||
* Note that you also need to return -1 in the case of error. | |||
* See individual description of entry points to implement below. | |||
* | |||
* @par Global KeySet Handle | |||
* | |||
* Global plugins and the resolver will get a handle to a global keyset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is it constructed and deleted?
Thank you! Please put the fixes (and further extensions) in a new PR. |
Basics
Adds a global keyset handle for global plugins #2270.
Get return value of global plugin calls.
See docs & release notes of PR.
Do not describe the purpose here but:
doc/news/_preparation_next_release.md which contains
*(my name)*
)Please always add something to the the release notes.
(first line should have
module: short statement
syntax)close #X
, should be in the commit messages.Checklist
Check relevant points but please do not remove entries.
For docu fixes, spell checking, and similar none of these points below
need to be checked.
Review
Remove the line below and add the "work in progress" label if you do
not want the PR to be reviewed: