Giter Club home page Giter Club logo

Comments (4)

eboasson avatar eboasson commented on September 12, 2024

There's currently no (official) way to add peers through the API. Unofficially, it can be done, but it won't be through a stable API (and I can already guarantee that it will break (in a trivial way) once I merge my work-in-progress.

Would you be interested in such an unofficial solution? It simply involves a few weird includes and scary function calls πŸ™‚

from cyclonedds.

m-mead avatar m-mead commented on September 12, 2024

Hi @eboasson, thank you for the reply. I'm still interested in the solution despite it being unofficial and likely to break πŸ™‚. I should mention that we are using the C++ CycloneDDS-cxx APIs, so if the APIs are not accessible from C++ then that is good to know too.

I did have another thought. Would the following work for discovering new peers without a full process restart?

  • Tear down the DDS participants in our system
  • Update the XML configuration file
  • Recreate the DDS participants in our system

I assume this would result in some messaging drops, but if it can avoid restarting the process then it could be a good middle ground solution between the unofficial APIs and a process restart.

from cyclonedds.

eboasson avatar eboasson commented on September 12, 2024

Once upon a time, there were two contrasting views on which header files to install and which to keep private. Some advocated only installing header files defining things related to the supported interface, others prefer installing everything and saying: "well, if you use this bit, we'll support you; if you use that bit, you're on your own".

I guess these days most people are in the first camp, I am mostly in the second camp β€” perhaps because I enjoyed the contents of /usr/include/sys/*.h way back when β€”Β but I do see the point in keeping things clean. For better or for worse, that means Cyclone is somewhere in between the extremes ... and of course that now means not everything one needs to update the set dynamically is available.

Fortunately, Cyclone is open source and so I can keep my promise πŸ˜„ This branch on my fork shows a possible way. It needed moving some stuff around in header files, and to avoid having to change the set of header files to install I also added a function that obviously is not supposed to be in the API. I guess it is quite self-explanatory if you look at the hello world publisher. Given that there will be some changes in this anyway, I think I should see whether there's a nice way for making this possible without having to hack it like this.

I should mention that we are using the C++ CycloneDDS-cxx APIs, so if the APIs are not accessible from C++ then that is good to know too.

Given that the above is such an ugly hack, it would probably be good to isolate it a bit. You can call the relevant C functions for C++ without any problem. The one thing you need is the handle for the C entity, that you can get from the C++ API by doing DomainParticipant dp(0); ... dp->get_ddsc_entity().

I did have another thought. Would the following work for discovering new peers without a full process restart?

  • Tear down the DDS participants in our system
  • Update the XML configuration file
  • Recreate the DDS participants in our system

Yep, that would work. It might be useful to know that you can also play tricks with the configuration because it doesn't have to really have to be one file. The CYCLONEDDS_URI is consumed piecewise where it looks at the first unprocessed character, and then:

  • if it is <, it starts parsing (a relaxed form of) XML until all tags have been closed or it runs into a parse error,
  • else it treats everything until the next comma as a URI (which may be just a file name)
    and then it eats up any commas, and repeats the above until it reaches the end. That "relaxed form" of XML accepts </> as a generic closing tag, uses unique prefix matching and allows you to skip the CycloneDDS and Domain bits.

So you can do a "proper" configuration file followed by a configuration file that really only defines peers, or you can even make a string that starts with the configuration file name, and then put the list of peers directly into the string.

There is also the dds_create_domain function in the C API which allows you to pass in the configuration string directly. This would allow you to avoid touching the CYCLONEDDS_URI contents or modifying the file system. In the C++ API this feature is available, too, there is a variant for the DomainParticipant constructor that takes the configuration string, like:

dds::domain::DomainParticipant(0, nullptr, nullptr, dds::core::status::StatusMask::none(), config);

from cyclonedds.

m-mead avatar m-mead commented on September 12, 2024

Wow, thank you for the really informative reply! This is all helpful, and I appreciate it. Also, I apologize for my delay in getting back to the thread -- I have been away on holiday.

The experimental APIs in your commit looks reasonable for us to support in a forked version, if the reinitialization time for the option involving updating the XML file ends up being too long. Would the project ever be interested in adding official support, or is that outside the scope of the public library interface?

from cyclonedds.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.