Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number of subscriptions #278

Open
jc211 opened this issue Dec 5, 2024 · 6 comments
Open

Number of subscriptions #278

jc211 opened this issue Dec 5, 2024 · 6 comments

Comments

@jc211
Copy link

jc211 commented Dec 5, 2024

Is there a way to quickly find out if a reader or a writer has been matched without using a WaitSet or a listener, and if so how many subscribers are on the other end? And possibly who they are?

@eboasson
Copy link
Contributor

eboasson commented Dec 5, 2024

Yes, it is possible. For a reader you can find out about matching writers:

  • dds_get_subscription_matched_status gives you number of matched writers
  • dds_get_matched_publications gives you a list of "instance handles" of matching writers
  • dds_get_matched_publication_data gives you details on a given writer

A similar trio of functions exists for a writer (the names change in the obvious way).

The dds_get_..._status call is really cheap (esp. when compared to the other two), so if you want to poll at a high frequency, use that one to decide whether or not to look more closely at the details.

@eboasson
Copy link
Contributor

eboasson commented Dec 5, 2024

I wasn't paying enough attention, it seems. You created an issue on the python repository, so presumably you want to do it in Python, not in C 🤦

It seems those functions are not (currently) available in the Python binding. It should be a straightforward addition, so if I am really lucky you're willing to try adding it and doing a PR. Otherwise, I (or someone else) can probably find some time in the near future ...

@jc211
Copy link
Author

jc211 commented Dec 5, 2024

I can give it a shot, but maybe you can point me in the right direction. What is the mechanism used here for creating the python bindings. It doesn't seem to be pybind (which I am most familiar with)?

@jc211
Copy link
Author

jc211 commented Dec 5, 2024

For example: to add dds_get_subscription_matched_status, would I add it after @c_call("dds_reader_wait_for_historical_data").

It would be

    @c_call("dds_get_subscription_matched_status")
    def _get_subscription_matched_status(self, reader: dds_c_t.entity, status: dds_c_t.status) -> dds_c_t.returnv:
        pass

I don't think dds_c_t.status exists though. Maybe its just an int?

@jc211
Copy link
Author

jc211 commented Dec 5, 2024

It actually looks like someone has done this already: da14e5b

@eboasson
Copy link
Contributor

eboasson commented Dec 9, 2024

It actually looks like someone has done this already: da14e5b

Oh dear. Now I really feel terrible.

Let me see if I can revive that effort, the basis of the binding hasn't changed so presumably it is still pretty close to what's needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants