-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
WIP: run against dbus-broker bench #23
Conversation
@elmarco the config changes are super desirable even w/o dbus-broker tests in mind. Do you think you can clean this up soon? |
src/bin/busd.rs
Outdated
let address = config | ||
.elements | ||
.iter() | ||
.rev() | ||
.find_map(|e| match e { | ||
config::Element::Listen(l) => Some(l), | ||
_ => None, | ||
}) | ||
.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think BusConfig
should provide specific API for each element so user doesn't have to deal with generic elements. It's exposing the detail that config is xml-based IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also bus module should be handling all this work. The main
should remain as thin as possible.
The bus config parsing requires XML.
The tests are from dbus reference implementation. The schema/dtd is a based on a mix of what is accepted by dbus and dbus-broker. Some tests are left with FIXME, as they may not fit in the config parser itself, but rather in the runtime handling of options. dbus has extra tests which may require installation to run (*.conf.in).
As we need require=false on the following patch.
Atm, we simply handle the last <listen> address!
f85e204
to
81d493d
Compare
@jokeyrhyme I have lost interest to help with this, I do not understand @zeenix project management. |
Oh, no worries, I can pick this up, hopefully this weekend 🤞 |
The list of elements idea was inspired by work performed by @elmarco over in dbus2#23 , which brings a lot of benefits that I was trying to provide using explicit low-level readers and writers of XML events: namely that we have access to element sequence (important for "last `<type>` wins" and the correct interpolation of `<include>`). serde offers a [try_from](https://serde.rs/container-attrs.html#try_from) attribute that allows us to abstract this away from the consumer.
The list of elements idea was inspired by work performed by @elmarco over in dbus2#23 , which brings a lot of benefits that I was trying to provide using explicit low-level readers and writers of XML events: namely that we have access to element sequence (important for "last `<type>` wins" and the correct interpolation of `<include>`). serde offers a [try_from](https://serde.rs/container-attrs.html#try_from) attribute that allows us to abstract this away from the consumer.
The list of elements idea was inspired by work performed by @elmarco over in dbus2#23 , which brings a lot of benefits that I was trying to provide using explicit low-level readers and writers of XML events: namely that we have access to element sequence (important for "last `<type>` wins" and the correct interpolation of `<include>`). serde offers a [try_from](https://serde.rs/container-attrs.html#try_from) attribute that allows us to abstract this away from the consumer.
The list of elements idea was inspired by work performed by @elmarco over in dbus2#23 , which brings a lot of benefits that I was trying to provide using explicit low-level readers and writers of XML events: namely that we have access to element sequence (important for "last `<type>` wins" and the correct interpolation of `<include>`). serde offers a [try_from](https://serde.rs/container-attrs.html#try_from) attribute that allows us to abstract this away from the consumer.
The list of elements idea was inspired by work performed by @elmarco over in dbus2#23 , which brings a lot of benefits that I was trying to provide using explicit low-level readers and writers of XML events: namely that we have access to element sequence (important for "last `<type>` wins" and the correct interpolation of `<include>`). serde offers a [try_from](https://serde.rs/container-attrs.html#try_from) attribute that allows us to abstract this away from the consumer.
We can deserialize an XML file using the "serde" and "quick-xml" crates. Creating a struct type with nested structs within is a direct approach that works well with `#[derive(Deserialize)]`. However, the result isn't optimal for consumption, and also makes it very difficult to implement aspects of the business logic that are sensitive to the order of certain XML elements, e.g. `<bus>`, `<include>`, etc. So our approach is to first deserialize into a `Vec<Element>` (inspired by @elmarco 's work over in dbus2#23 ). Importantly, by starting with this intermediate representation, we can preserve the XML author's intention regarding the order of elements. Then we replace any `<include>` and `<includedir>` elements with the parsed contents the XML files to which they refer, further replacing any `<include>` and `<includedir>` elements within those. Finally, we can make one final iteration over the `Vec<Element>` to produce the final optimally-structured `Config`. Fixes dbus2#78
This series allows to run busd against dbus-broker benchmark, with:
The most important change is the introduction of
<busconfig>
parsing, and then handling of a few command line options.The test currently hangs after what looks like an initial successful connection. Further investigation needed.
/!\ This branch needs dbus2/zbus#390