-
Notifications
You must be signed in to change notification settings - Fork 89
Add persist mode support #964
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
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 adds support for the PersistMode property to JetStream StreamConfig, enabling users to configure different persistence modes for streams (supported from NATS server v2.12+). The implementation includes proper serialization/deserialization handling and comprehensive test coverage.
- Introduces
StreamConfigPersistModeenum withDefaultandAsyncvalues - Adds
PersistModeproperty toStreamConfigclass with JSON serialization attributes - Updates JSON serializers to handle the new enum with snake_case conversion
- Includes tests for creation, retrieval, and update validation of persist mode settings
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| StreamConfigPersistMode.cs | Defines new enum for persist mode values |
| StreamConfig.cs | Adds PersistMode property with JSON serialization configuration |
| NatsJSJsonSerializer.cs | Updates enum converters to handle StreamConfigPersistMode serialization |
| ManageStreamTest.cs | Adds comprehensive test coverage for persist mode functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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
Change `PersistMode` to nullable and adjust serialization to exclude it when null. Add tests to confirm correct serialization/deserialization behaviors and align with server's behavior for handling default or absent values.
# Conflicts: # src/NATS.Client.JetStream/Models/StreamConfig.cs # tests/NATS.Client.JetStream.Tests/ManageStreamTest.cs
This pull request adds support for the new
PersistModeproperty to the JetStreamStreamConfig, enabling users to specify different persistence modes for streams (supported from server v2.12). It introduces a new enum for persist modes, updates serialization/deserialization logic, and adds comprehensive tests to ensure correct behavior and error handling.PersistMode property support in StreamConfig:
PersistModeproperty of typeStreamConfigPersistModeto theStreamConfigclass, allowing configuration of stream persistence mode. This property is serialized as"persist_mode"and defaults toDefault.StreamConfigPersistModeenum with valuesDefaultandAsync.Serialization and deserialization updates:
StreamConfigPersistModeusing snake_case string values for both reading and writing. [1] [2] [3]Testing enhancements:
PersistModeproperty is correctly set, persisted, and validated on stream creation, and that updating the property results in the expected server error.