[SR-Users] Invoking RPC commands over HTTP

Ben Hood 0x6e6562 at gmail.com
Fri Mar 2 18:46:03 CET 2018


Hey Aleksandar,

Many thanks for the heads up - very interesting to see how other
people are doing this.

So if I understand you correctly, you have a dynamic list of dispatchers.

And then you invoke "dispatcher.reload" to reload all of the
dispatchers you have defined dynamically?

What does the  DISPATCHER_LIST route look like?

Cheers,
Ben


On Fri, Mar 2, 2018 at 9:29 AM, Aleksandar Sosic <alex.sosic at timenet.it> wrote:
> Hi Ben,
>
> we're using something like this to do dispatcher.reload:
>
> ```
> event_route[xhttp:request] {
> if ($hu =~ "^/rpc") {
> $var(command) = $(hu{s.select,2,/});
> $var(parameter) = $(hu{s.select,3,/});
>
> if($var(command) == "reload.dispatchers") {
> route(DISPATCHER_LIST);
> xhttp_reply("200", "OK", "text/html", "Dispatchers Set for RELOAD");
> exit;
> }
> ...
> }
> ```
>
> And then in the DISPATCHER_LIST route we do an API call for fetching
> the updated dispatcher list for that node.
> After the dispatcher list is updated we just run:
> jsonrpc_exec('{"jsonrpc": "2.0", "method": "dispatcher.reload", "id": "1"}');
>
> So you can just put a `jsonrpc_exec` inside the event_route[xhttp:request].



More information about the sr-users mailing list