dbus2 / zbus-old

Rust D-Bus crate.
https://gitlab.freedesktop.org/dbus/zbus
Other
49 stars 13 forks source link

ObjectServer with multiple Connection #187

Closed zeenix closed 1 year ago

zeenix commented 3 years ago

In GitLab by @DataTriny on Jul 17, 2021, 13:28

Hello,

I am trying to build a D-Bus server application that connects to a private bus (let's call it A). For performance reasons, one of the interfaces I need to implement must expose a method (let's call it GetBusAddress) that return the address of another private bus I should create myself (let's call it bus B).

A typical workflow look like this:

The problem here is that my server must expose the whole object tree on both buses. The only solutions I see around this are:

My question then is: is handling this situation part of the plans for zbus?

Thanks in advance.

Kind regards,

zeenix commented 3 years ago

@DataTriny I'm currently on vacation. I'll reply when I'm back later this week.

zeenix commented 3 years ago

maintain two copies of the tree (one ObjectServer for each Connection: I don't think this is a good idea as the tree can get pretty big,

Are you certain that size of the tree is very relevant here? As long as you don't duplicate a lot of state (for which you can use Arc etc) between them, your code's memory usage should be pretty minimum. ObjectServer OTOH uses allocated strings for object paths though (not interfaces though) so that will have an impact but I'd check if it's large enough in your case to worry about.

handle message dispatching on my own: this would be possible but rather hard I guess.

If the ObjectServer duplication isn't an option for you, I'm afraid this is the only alternative you're left with. You'll need to use the low-level (Connection) API instead. It might feel like a lot of work but for such special use cases, I think it's not too bad but that's just my opinion. :)

My question then is: is handling this situation part of the plans for zbus?

We don't have any plans for such cases but if you've suggestion on how we can support that, please feel free to suggest.

zeenix commented 3 years ago

@DataTriny ping?

zeenix commented 3 years ago

In GitLab by @danieldg on Aug 3, 2021, 02:30

Note that if you ever want to expose any differences between the two buses, you'll need to split the ObjectServer anyway - and I suspect you will eventually want to do that. You can still use Arc as suggested to share the large (common) parts of the tree.

zeenix commented 3 years ago

@DataTriny ObjectServer is now Sync+Send in the main branch btw.