Skip to content

Conversation

@mtmk
Copy link
Member

@mtmk mtmk commented Sep 25, 2025

This pull request adds support for the new PersistMode property to the JetStream StreamConfig, 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:

  • Added a new PersistMode property of type StreamConfigPersistMode to the StreamConfig class, allowing configuration of stream persistence mode. This property is serialized as "persist_mode" and defaults to Default.
  • Introduced the StreamConfigPersistMode enum with values Default and Async.

Serialization and deserialization updates:

  • Updated the custom JSON serializer to handle StreamConfigPersistMode using snake_case string values for both reading and writing. [1] [2] [3]

Testing enhancements:

  • Added a test to verify that the PersistMode property is correctly set, persisted, and validated on stream creation, and that updating the property results in the expected server error.
  • Minor test import cleanup.

@mtmk mtmk requested review from Copilot and scottf September 25, 2025 11:23
Copy link
Contributor

Copilot AI left a 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 StreamConfigPersistMode enum with Default and Async values
  • Adds PersistMode property to StreamConfig class 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.

Copy link
Contributor

@scottf scottf left a comment

Choose a reason for hiding this comment

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

LGTM

@mtmk mtmk added the testing label Sep 25, 2025
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
@mtmk mtmk merged commit 47d3136 into main Sep 29, 2025
27 of 29 checks passed
@mtmk mtmk deleted the 2.12/persist-mode branch September 29, 2025 09:04
mtmk added a commit that referenced this pull request Oct 1, 2025
* Add Prioritized Priority Consumer Policy (#965)
* Add persist mode support (#964)
* Add support for message schedules (#963)
* Add Atomic Publish Support (#962)
* Counter support for server v2.12 (#960)
@mtmk mtmk mentioned this pull request Oct 1, 2025
mtmk added a commit that referenced this pull request Oct 1, 2025
* Add Prioritized Priority Consumer Policy (#965)
* Add persist mode support (#964)
* Add support for message schedules (#963)
* Add Atomic Publish Support (#962)
* Counter support for server v2.12 (#960)
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