-
Notifications
You must be signed in to change notification settings - Fork 89
Counter support for server v2.12 #960
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
Counter support for server v2.12 #960
Conversation
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 implements JetStream message counter support for NATS server v2.12, enabling streams to track and increment/decrement counters via message headers. The implementation follows ADR-49 specifications by adding configuration options and response value handling.
- Added
AllowMsgCounterproperty toStreamConfigfor enabling counter functionality - Enhanced
PubAckResponseto include counter value in publish acknowledgments - Comprehensive test coverage for counter operations and error scenarios
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/NATS.Client.JetStream/Models/StreamConfig.cs | Adds AllowMsgCounter boolean property to enable message counters in stream configuration |
| src/NATS.Client.JetStream/Models/PubAckResponse.cs | Adds optional Value property to return counter values in publish acknowledgments |
| tests/NATS.Client.JetStream.Tests/CounterTest.cs | Implements comprehensive test suite covering counter operations, error handling, and feature validation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
scottf
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
| /// <remarks>Supported by server v2.12</remarks> | ||
| [System.Text.Json.Serialization.JsonPropertyName("allow_msg_counter")] | ||
| [System.Text.Json.Serialization.JsonIgnore(Condition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingDefault)] | ||
| public bool AllowMsgCounter { get; set; } |
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.
this should be nullable
Support implementation of ADR-49
This pull request adds support for the JetStream message counter feature introduced in NATS server v2.12. It introduces a new property to enable message counters in stream configurations, updates the publish acknowledgment response to include the counter value, and adds comprehensive tests to verify the new functionality and error handling.
JetStream message counter support:
AllowMsgCounterproperty to theStreamConfigmodel, allowing streams to enable or disable message counters. This property is serialized asallow_msg_counterand is supported from server v2.12.PubAckResponsemodel to include an optionalValueproperty (serialized asval), which returns the current counter value when publishing messages with counter headers.Testing:
CounterTestclass to verify message counter functionality, including incrementing, decrementing, using multiple counters, and ensuring proper error handling when the feature is disabled.