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

ConfigurationOptions: observe modifications after ConnectionMultiplexer start #2050

Merged
merged 11 commits into from
Mar 26, 2022

Conversation

NickCraver
Copy link
Collaborator

@NickCraver NickCraver commented Mar 20, 2022

Overall changes:

  • Biggest: ConfgurationOptions passed into a ConnectionMultiplexer.Connect*() method is no longer cloned. This means it can be modified after connecting and changes will take effect on the next access. For example a user can rotate passwords or change timeouts on the fly.
    • A few things like EndPoints are cloned and memoized to ConnectionMultiplexer and changing them is not respected because this creates paradoxes and races in the multiplexer. These are explicitly called out in ConfigurationOptions docs.
  • Moves IncludeDetailInExceptions and IncludePerformanceCountersInExceptions from ConnectionMultiplexer to ConfigurationOptions (with backwards compatible APIs).
    • Should we [Obsolete] now?
  • Move to a cleaner TryGetTieBreaker approach instead of Sentinel defaults needing to set it.
  • SetDefaultPorts is now more cleanly based on ServerType (rather than a sentinel bool everywhere...that felt icky.
  • Config validation is centralized

TODO:

  • Docs on each ConfigurationOptions memoized property to make clear it was copied and has no effect after connection.
  • Tests exercising config changes post-connect
  • Release notes
  • Question: obsolete ConnectionMultiplexer.IncludeDetailInExceptions and ConnectionMultiplexer.IncludePerformanceCountersInExceptions?

- Moves IncludeDetailInExceptions and IncludePerformanceCountersInExceptions from ConnectionMultiplexer to ConfigurationOptions (with backwards compatible APIs).
- Move to a cleaner TryGetTieBreaker approach instead of Sentinel defaults needing to set it.
This needs a suite of tests but basically we're cloning the bits we don't want to fork from RawConfig (ConfigurationOptions ref on ConnectionMultiplexer). This may seem minor, but the net impact is a user can hold on to a ConfigurationOptions passed in and further modify it, e.g. to rotate passwords, etc. upstream. A few things we still clone are called out explicitly in the ConfigurationOptions docs.
This hasn't worked in some time - properly [Obsolete] it and point to the effective option on SocketManagerOptions.
@NickCraver NickCraver changed the title ConfigurationOptions: allow modification after ConnectionMultiplexer start ConfigurationOptions: observe modification after ConnectionMultiplexer start Mar 20, 2022
@NickCraver NickCraver marked this pull request as ready for review March 20, 2022 16:03
@NickCraver NickCraver changed the title ConfigurationOptions: observe modification after ConnectionMultiplexer start ConfigurationOptions: observe modifications after ConnectionMultiplexer start Mar 21, 2022
@NickCraver NickCraver merged commit 4dccb0a into main Mar 26, 2022
@NickCraver NickCraver deleted the craver/config-cleanup branch March 26, 2022 00:41
NickCraver added a commit that referenced this pull request Aug 19, 2023
ILogger support - since we support `Action<ConfigurationOptions>` this can be added today e.g. with `o => o.LoggerFactory = myLoggerFactory`:
```cs
var muxer = ConnectionMultiplexer.Connect("localhost", o => o.LoggerFactory = myLoggerFactory);
```
...or we could add sibling overloads to the existing `TextWriter`. I'd love to not create a ^2 matrix every time we do this, though. Starting simpler for that reason. Note: this is on top of #2050 for simplicity, will roll against `main` when merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants