Skip to content

CSHARP-3745: Add support for srvServiceName URI option #1284

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

Merged
merged 10 commits into from
Mar 14, 2024

Conversation

adelinowona
Copy link
Contributor

  • Added a new URI options srvServiceName which allows the user to change the srv address prefix from the default of mongodb

@adelinowona adelinowona requested a review from a team as a code owner March 6, 2024 22:35
@adelinowona adelinowona removed the request for review from a team March 6, 2024 22:35
Copy link
Contributor

@JamesKovacs JamesKovacs left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -928,6 +937,11 @@ private void Parse()
throw new MongoConfigurationException("Specifying srvMaxHosts when connecting to a replica set is invalid.");
}

if (!_isInternalRepresentation && _srvServiceName != null && _scheme != ConnectionStringScheme.MongoDBPlusSrv)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not very clear from the flow, why do we limit this check to _isInternalRepresentation ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So _isInternalRepresentation helps to differentiate between a connection string provided by the user and one that has been transformed into a mongodb:// after the SRV and TXT records are resolved from DNS. So we need to check the connection string before the transformation has happened.

/// <summary>
/// Gets the SRV service name.
/// </summary>
public static string SrvServiceName
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe place it in MongoInternalDefaults and reuse in ConnectionString ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@adelinowona adelinowona requested a review from BorisDog March 13, 2024 19:39
Copy link
Contributor

@BorisDog BorisDog left a comment

Choose a reason for hiding this comment

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

LGTM

@adelinowona adelinowona merged commit b0fbe1d into mongodb:master Mar 14, 2024
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.

3 participants