-
Notifications
You must be signed in to change notification settings - Fork 89
chore: rework NatsOpt.Default initialization #921
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
Conversation
|
thanks @regnrat. Looking good. Are there any cases you can think of this might break an existing app? edit: if we think it might break existing apps in any way we can change the base to 2.7 release branch. |
|
I think you can construct situations where this breaks an application, in theory. But that would require unclean code on the consumers side and wouldn't make any sense. But theoretical yes. Shall I change the base? |
Yes, i think we should. we've been using minor version updates to signal potentially breaking API changes. |
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.
Pull Request Overview
This PR refactors the initialization of NatsOpts.Default to use sub-property default objects while changing the default constructor to create new instances of sub-properties. This ensures proper object isolation when binding configurations to different NatsOpts instances.
- Changes
NatsOpts.Defaultto explicitly set sub-properties to their respective static defaults - Updates default constructor property initializers to use
new()instead of static defaults - Adds comprehensive tests to verify object isolation and configuration binding behavior
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/NATS.Client.Core/NatsOpts.cs | Restructures NatsOpts.Default initialization and updates constructor property defaults |
| tests/NATS.Client.CoreUnit.Tests/OptsTests.cs | Adds new test class with tests for default equivalence and configuration binding isolation |
| tests/NATS.Client.CoreUnit.Tests/NATS.Client.CoreUnit.Tests.csproj | Adds Microsoft.Extensions.Configuration packages for configuration binding tests |
Comments suppressed due to low confidence (1)
tests/NATS.Client.CoreUnit.Tests/OptsTests.cs:4
- The class name 'OptsUrlTests' is misleading as the tests are about NatsOpts behavior, not URL-specific functionality. Consider renaming to 'NatsOptsTests' or 'OptsTests' to better reflect the actual test content.
public class OptsUrlTests
mtmk
left a comment
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.
LGTM thanks @regnrat
* #863 Fix naming of consumer group attribute (#870) Signed-off-by: James Thompson <[email protected]> * #848 Tweak dependencies (#853) * #848 Tweak dependencies Signed-off-by: James Thompson <[email protected]> * Update NATS.Client.Core.csproj Signed-off-by: James Thompson <[email protected]> * Update NATS.Client.Core.csproj Signed-off-by: James Thompson <[email protected]> * Make STJ explicit dependency for JetStream Signed-off-by: James Thompson <[email protected]> * Update NATS.Client.JetStream.csproj Signed-off-by: James Thompson <[email protected]> * Force sdk to 8.0.0 Signed-off-by: James Thompson <[email protected]> * Add newer stj for net 6 Signed-off-by: James Thompson <[email protected]> --------- Signed-off-by: James Thompson <[email protected]> * Add support for `Filter` and `Enrich` for OpenTelemetry activities (#859) * Add support for `Filter` and `Enrich` for OpenTelemetry activities * Make `internal` methods in `internal Telemetry` `public` * Fix package versions and whatnot * Remove `TracerProviderBuilderExtensions` * Include `Deserialize` in the receive activity * Revert back accidental change * Add `ParentContext` to `NatsInstrumentationContext` * Make `GetActivityContext` public to provide the ability to get context activity context * Make preprocessor directive more accurate * Revert .csproj formatting * Move public artifacts out of the `Internal` namespace/folder * Fix build script --------- Co-authored-by: Ziya Suzen <[email protected]> * Obsolete ReplyAsync method for NatsJsMsg (#839) * Obsolete ReplyAsync method * Obsolete ReplyAsync method on interface * #851 Move Serialization Interface into Abstractions (#858) * Tweaks Signed-off-by: James Thompson <[email protected]> * Add missing dependencies Signed-off-by: James Thompson <[email protected]> * switch to system.memory Signed-off-by: James Thompson <[email protected]> * Added missing using Signed-off-by: James Thompson <[email protected]> * Reduce csproj file contents Signed-off-by: James Thompson <[email protected]> --------- Signed-off-by: James Thompson <[email protected]> * Release 2.7.0-preview.1 (#905) * #851 Move Serialization Interface into Abstractions (#858) * Obsolete ReplyAsync method for NatsJsMsg (#839) * Add support for `Filter` and `Enrich` for OpenTelemetry activities (#859) * #848 Tweak dependencies (#853) * #863 Fix naming of consumer group attribute (#870) * fix: `NatsInstrumentationOptions.Default` gets reset each time (#907) * initialize `NatsInstrumentationOptions.Default` once * `NatsInstrumentationContext.ActivityContext` doesn't need to be nullable * no need for `GetActivityContext` on NatsJSMsg * Release 2.7.0-preview.2 (#908) * fix: `NatsInstrumentationOptions.Default` gets reset each time (#907) * Also, fixes from main * Fix build warnings (#912) * fix: `NatsJSConsumer` never disposing receive activities (#911) * Fix `NatsJSConsumer` never disposing receive activities * Use `ActivityEndingMsgReader` to `NatsJSFetch` and `NatsJSOrderedConsume` * Consolidate activity ending message readers into one class * Run `dotnet format` * Release 2.7.0-preview.3 (#922) * fix: `NatsJSConsumer` never disposing receive activities (#911) * Merge from main * chore: rework NatsOpt.Default initialization (#921) * chore: rework NatsOpt.Default initialization * chore: removed unused using statement * Fix kv ttl interface (#909) KV TTL should only be allowed on Create and Purge * Release 2.7.0-preview.4 (#931) Fixes merged from main * Release 2.7.0-preview.5 (#944) Merge from main aligning with 2.6.8 release. * Fix JetStream publish retry defaults (#939) Decision to retry jetstream publish requests should be letft to the application since it depends on the delivery and durability requirements of their solution. * Fix publish 503 test (#958) With 2.7.x we have made the default to not re-publish on failure. * Release 2.7.0-preview.6 (#956) * Fix JetStream publish retry defaults (#939) * Merge from main * Release 2.7.0-preview.7 (#970) Merged from main * fix: handle 408 Requests Pending responses for fetch requests (#973) * Handle 408 Requests Pending responses for fetch requests * Remove redundant `Console.WriteLine` that was put there for testing * Release 2.7.0-preview.8 (#986) * fix: handle 408 Requests Pending responses for fetch requests (#973) * (merge from main) Object store item size fix (#977) * Fix Ad-Hoc JSON Serializer to use Default Options (#984) * Fix connection state for consume (#959) * Fix connection state for consume * Enhance connection state handling with NatsConnectionFailedException * Improve error handling for connection failures and add support for configurable 503 error thresholds in JetStream consumers * Add tests for connection failure handling and configurable 503 error thresholds in JetStream consumers * Fix format * Fix test * Update INatsJsConsumer to return INatsJsMsg (#1004) --------- Signed-off-by: James Thompson <[email protected]> Co-authored-by: James Thompson <[email protected]> Co-authored-by: Arad Alvand <[email protected]> Co-authored-by: Yeong Jong Lim <[email protected]> Co-authored-by: regnrat <[email protected]>
* Replace `OperationCanceledException` with `NatsTimeoutException` (#1022) * Replace deprecated IndexRange package with Microsoft.Bcl.Memory to solve possible dependency conflicts (for netFramework/netStandard2.0) (#1009) * PeerInfo.Lag is wrong type (#1021) * (Merge Branch) Release 2.7 (#874) * Update INatsJsConsumer to return INatsJsMsg (#1004) * Fix connection state for consume (#959) * Fix Ad-Hoc JSON Serializer to use Default Options (#984) * fix: handle 408 Requests Pending responses for fetch requests (#973) * Fix publish 503 test (#958) * Fix JetStream publish retry defaults (#939) * Fix kv ttl interface (#909) * chore: rework NatsOpt.Default initialization (#921) * fix: `NatsJSConsumer` never disposing receive activities (#911) * Fix build warnings (#912) * fix: `NatsInstrumentationOptions.Default` gets reset each time (#907) * #851 Move Serialization Interface into Abstractions (#858) * Obsolete ReplyAsync method for NatsJsMsg (#839) * Add support for `Filter` and `Enrich` for OpenTelemetry activities (#859) * #848 Tweak dependencies (#853) * #863 Fix naming of consumer group attribute (#870)
* Replace `OperationCanceledException` with `NatsTimeoutException` (#1022) * Replace deprecated IndexRange package with Microsoft.Bcl.Memory to solve possible dependency conflicts (for netFramework/netStandard2.0) (#1009) * PeerInfo.Lag is wrong type (#1021) * (Merge Branch) Release 2.7 (#874) * Update INatsJsConsumer to return INatsJsMsg (#1004) * Fix connection state for consume (#959) * Fix Ad-Hoc JSON Serializer to use Default Options (#984) * fix: handle 408 Requests Pending responses for fetch requests (#973) * Fix publish 503 test (#958) * Fix JetStream publish retry defaults (#939) * Fix kv ttl interface (#909) * chore: rework NatsOpt.Default initialization (#921) * fix: `NatsJSConsumer` never disposing receive activities (#911) * Fix build warnings (#912) * fix: `NatsInstrumentationOptions.Default` gets reset each time (#907) * #851 Move Serialization Interface into Abstractions (#858) * Obsolete ReplyAsync method for NatsJsMsg (#839) * Add support for `Filter` and `Enrich` for OpenTelemetry activities (#859) * #848 Tweak dependencies (#853) * #863 Fix naming of consumer group attribute (#870)
Creating NatsOpts.Default with sub property default objects:
Using default constructors for these sub properties in default constructor of NatsOpts.
Closes #920