-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introducing LY_CTX_BASIC_PLUGINS_ONLY & LYPLG_TYPE_STORE_ONLY #2171
Introducing LY_CTX_BASIC_PLUGINS_ONLY & LYPLG_TYPE_STORE_ONLY #2171
Conversation
Some background:
This last one is not really a problem of
For these cases usage of an opaque node is very problematic as it requires to store |
d65efe2
to
a8f7f4a
Compare
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.
Okay, I think your use-case can be supported but using a different design that may even improve things overall. It can be divided into 2 independent parts:
-
New context flag for it to avoid using (loading) any type plugins except for the basic ones for the built-in YANG types. I believe this should also include external plugins (which you have not disabled in this PR).
-
New internal type plugin option
LYPLG_TYPE_STORE_ONLY
which would be set for every store callback called when parsing data withLYD_PARSE_ONLY
and would mean that the callback can skip all validation tasks that would not prevent the value from being stored successfully.You have mostly implemented this already leading to more
validate
callbacks, which would not be called instore
if the new option is set (and never returnLY_EINCOMPLETE
), called otherwise. This would lead to another important change in the background, some validate callbacks would need the data tree (current ones) and some not (the new ones). I am not certain this is relevant and everything will probably be fine if this difference is ignored and the data are always provided tovalidate
(because it would normally be called as part ofstore
when data are not needed just like now).This will also lead to more efficient
LYD_PARSE_ONLY
that would skip redundant type validation. Also, as you mentioned, you will need this new functionality not only as part oflyd_parse()
so you can add functions such aslyd_new_term_store_only()
, not sure if you need anything else.
PS: Sorry it took me a while, busy last few days.
On 1st point:
On 2nd point:
|
|
a8f7f4a
to
8e216c9
Compare
8e216c9
to
8860204
Compare
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.
Without looking at this in much detail, I meant it when I said that you can add new functions for the store-only flag, please do not modify the current ones. This is not about backwards-compatibility, they already have one annoying parameter (output
), they do not need another. Also, this makes sense only for a few functions such as lyd_new_term()
and okay, even lyd_new_list()
or lyd_new_meta()
.
Well adding a new variant of public calls seem to be quite odd..... how about converting Or do it totally different and say that all |
Was thinking about that but I do not think it is really desired, in general, to not get an error on an invalid value. But the One just needs to sanitize the options because some should not be combined. Specifically:
Also, the Actually, these options should then be merged with |
One side question coming from utest modifications. Is there a reason why |
Right, not sure about that one. I do not think it is such a problem that A solution may be adding a new parsing flag, one would use |
I have accidentally push incomplete patch, no review is needed yet. I will let you know once finished on my side |
b50a0f6
to
d0eb796
Compare
Ok, now it should be the ready for review |
a6fab9c
to
e9c8c5e
Compare
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.
So again, thanks for the effort, a lot of changes were required. Unfortunately, I have not realized that adding the binary value option to the new
functions would add another parameter (value length) and make the value void *
instead of char *
. I would really prefer to avoid changes requiring rewriting of all these functions usage in existing code (as long as no options are needed) so I have to ask you to keep this single variant (_bin
) in a separate function. However, the documentation still needs to be improved significantly and I see no point in adding all those comments so I will do that separately after merging this PR and I could also make the binary value change, up to you.
Another thing, please change the target branch to new_so
, these changes cannot simply be merged into devel
, the other projects needs to be synced first with the changes.
Additional note, lyplg_type_check_hints()
should probably be a part of validate
callbacks as well, it does not affect the storing process.
I have put back the I deliberately kept |
e9c8c5e
to
2f8f0d8
Compare
2f8f0d8
to
aa5419d
Compare
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.
Almost there, hopefully some final adjustments needed.
Regarding I am talking mainly about encoding problems that if a number is encoded as a string, it can still be stored and the validation should fail. However, hints are not available in the validate callback and it is not worth it to add them there so leave it the way it is then. |
This patch separates the build-in type validations from store operations to allow storing a node even if the value doesn't pass the validations. To do multiple changes were done: - introduces LY_CTX_BASIC_PLUGINS_ONLY flag, which prevents loading of any advanced plugins - introduces LYPLG_TYPE_STORE_ONLY flag, which skip validation and perform just storing - introduces LYD_PARSE_STORE_ONLY flag, which implies usage of LYPLG_TYPE_STORE_ONLY - introduces options for lyd_new_* API - removes lyd_new_(term|list)_(bin|canon) API - added sanity checks within lyd_new_(term|list) APIs for proper combinations of options - refactored lyd_new_* APIs to use common flags to use common options attributes
aa5419d
to
b970d5a
Compare
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.
Seems fine now, thanks, I will now improve the documentation myself.
) This patch separates the build-in type validations from store operations to allow storing a node even if the value doesn't pass the validations. To do multiple changes were done: - introduces LY_CTX_BASIC_PLUGINS_ONLY flag, which prevents loading of any advanced plugins - introduces LYPLG_TYPE_STORE_ONLY flag, which skip validation and perform just storing - introduces LYD_PARSE_STORE_ONLY flag, which implies usage of LYPLG_TYPE_STORE_ONLY - introduces options for lyd_new_* API - removes lyd_new_(term|list)_(bin|canon) API - added sanity checks within lyd_new_(term|list) APIs for proper combinations of options - refactored lyd_new_* APIs to use common flags to use common options attributes
This patch separates the build-in type validations from store operations to allow storing a node even if the value doesn't pass the validations. To do that a new context option was introduced:
LY_CTX_STORE_INVALID_DATA
This option also prevent loading of advanced plugins, which cannot really separate store and validation operations