I am new to Confd and wanted to utilize the delayed asynch response to an Action Callback. I am currently using the CONFD_DELAYED_RESPONSE as a return for the Action callback.
My query is that is it possible to have an delayed Action Response when the application is ready to provide the value, other than an error or an OK i.e. a custom string value returned via reply_action_values called asynchronously?
Yes, otherwise the possibility to return CONFD_DELAYED_RESPONSE would be of very limited value. It seems it isn’t specifically documented for action callbacks, but the general principle described in the section “Delayed Replies” in the “Operational Data” chapter of the User Guide applies there too. I.e. if you would have called a specific reply function - in this case confd_action_reply_values()
- from within the callback if you hadn’t returned CONFD_DELAYED_RESPONSE, you just call the same reply function when you have the data available. The “special” functions like confd_action_delayed_reply_ok()
and confd_action_delayed_reply_error()
are only needed when the callback would have returned CONFD_OK or CONFD_ERR, i.e. not used any specific reply function.
thanks! Yes I tried it out and it seems to work but for the callback which calls the DELAYED_RESPONSE seems to be blocking the CI from executing any other commands. I believe DELAYED_RESPONSE was intended to provide asynchronous replies without blocking the CLI.
No, the only purpose of DELAYED_RESPONSE is to let you “get out” of the callback and e.g. return to your poll loop to receive some IPC message. It is implemented entirely in the libconfd library, invisible from the ConfD server’s point of view.
If you want really asynchronous, in the general case you would need one “start” action and one “collect-result” action (or possibly a notification). For CLI only, another possibility might be a clispec-defined command that uses the batch
option.