bond::Bond() and bond id discovery

asked 2018-10-15 00:07:03 -0500

KenYN gravatar image

updated 2018-10-15 00:09:26 -0500

As far as I can tell, there is no discovery mechanism built in to the bond::Bond node. My use case is that I want to develop a generic Watchdog node that monitors two nodes at either end of a topic (or whatever) like this:

/node/one  <===Bond===> Watchdog <===Bond===> /node/two

So, if /node/one dies, the Watchdog can take some action with /node/two. Hard-coding IDs seems error-prone and awkward for arbitrary connections, so I wonder is there is a simple solution here. Ideally I would want to write a mixin class that I can add to my nodelets with just a single line, and the most obvious solution to me is advertising a well-known service on each node like so:

/node/one                    Watchdog                  /node/two
                             node1.request("/watchdog/bond", "bond_123456")
Check "bond_123456" OK
return OK (or alternative ID)
                             x = make_unique<>("/watchdog/bond", "bond_123456")
                             x->start(); x->WaitUntilFormed();
b = make_unique<>("/watchdog/bond", "bond_123456")
   <===Bond established===>
                             node1.request("/watchdog/bond", "bond_987654")
                                                        "bond_987654" is not OK
                                                        return "bond_555555"
                             y = make_unique<>("/watchdog/bond", "bond_555555")
                             y->start(); y->WaitUntilFormed();
                                                        b = make_unique<>("/watchdog/bond", "bond_555555")
                              <===Bond established===>

Thus, by adding suitable parameters to the Watchdog node and an extra parent class to existing nodes, I can monitor two arbitrary node and if one crashes I can inform the other.

So my questions are first, does what I am trying to do exist? And second, if it doesn't, does it make sense?

edit retag flag offensive close merge delete