based on documentation I think the regular approach to adding transaction hooks is to:
1/ add transaction hook entries in YANG
2/ start daemon who will do following:
2.1/ register transaction callbacks (init, finish) in order to connect and attach to transaction and eventual do cleaning up
2.2/ register data callbacks (create, remove, set_elem).
It works if you accept one hindrance: there’s no ‘modify’ callback ?!?
Now this is strange, because if you do maapi_diff_iterate in your init callback then you are getting ‘modify’ operations.
And sometimes modify is what you need because you need to take one action based on overall change in parent (all children) not individual children. It’s awkward to implement the action if you get set_elem, create or remove on each child separately…
This makes me wonder:
A/ is it possible to somehow get this ‘modify’ callback?
B/ maybe init and finish is all I need to implement hooks by myself (without adding callpoints in YANG and no data callbacks):
B1/ Just keep list of keypaths I’m interested in and use it with maapi_diff_iterate or maapi_keypath_iterate to filter them out in ‘init’ callback.
B2/ I get ‘init’ callback’ for any transaction anyway, right?
B3/ No need to modify/deploy changes in YANG if you need to add another hook, just application needs to be rebuilt and deployed.
B4/ Or is it going to be too slow compared to regular approach because of all that maapi_diff_iterate on each transaction (suppose my app may add hooks anywhere in the YANG in future) ?
or C/ use hybrid approach, that is use regular callpoints for create, remove and set_elem operations and maapi_diff_iterate for the ‘modify’ operations? That seems like the most efficient way?