Skip to content

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Sep 15, 2025

RUST-2203 / RUST-2272

This required moving metadata from something that each worker has its own copy of to a central per-Client (actually per-Topology) shared value.

I initially implemented this as an update that gets fanned out to the workers using the existing infrastructure that's there for shutdown and the like; that turned out to require a centralized copy anyway so I dropped the fan-out. In the process, though, I did some refactoring of the related methods so that worker commands require fewer intermediate pass-through wrapper methods and division of logic among the components is clearer.

pub(crate) async_event_listener: Option<TestEventSender>,

/// Callback to receive hello commands.
pub(crate) hello_cb: Option<EventHandler<crate::cmap::Command>>,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prose tests required direct visibility of hello commands, so new test hook. I used EventHandler for this because that's easier than typing Arc<Box<dyn Fn(crate::cmap::Command)>> all over the place and it already implements things like Debug.


impl From<&ClientOptions> for EstablisherOptions {
fn from(opts: &ClientOptions) -> Self {
impl From<&TopologySpec> for EstablisherOptions {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because Establisher / Handshaker now require a value outside of ClientOptions to construct, I introduced TopologySpec to capture that (and anything similar that happens to be needed in the future) rather than thread through another function parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were just construction tests of metadata values and IMO didn't have enough utility to be worth updating.

@abr-egn abr-egn marked this pull request as ready for review September 16, 2025 12:54
@abr-egn abr-egn requested a review from a team as a code owner September 16, 2025 12:54
@abr-egn abr-egn marked this pull request as draft September 16, 2025 16:38
@abr-egn abr-egn marked this pull request as ready for review September 17, 2025 17:28
Copy link
Contributor

@isabelatkinson isabelatkinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just FYI, I was confused about the ambiguity that comes with omitting unspecified fields, but looks like there's an open DRIVERS ticket to address this blocked on changes from analytics: https://jira.mongodb.org/browse/DRIVERS-3251

}

impl ClientMetadata {
pub(crate) fn append(&mut self, driver_info: DriverInfo) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec has the following requirement:

All strings provided as part of the driver info MUST NOT contain the delimiter used for metadata concatention. Drivers MUST throw an error if any of these strings contains that character.

So we should be checking for "|" in these strings - I think we're also missing that for metadata included in ClientOptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, added.

Co-authored-by: Isabel Atkinson <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants