Skip to content

Conversation

@mtmk
Copy link
Member

@mtmk mtmk commented Sep 4, 2025

Prepare for jetstream batch update and related functions.

This pull request introduces support for specifying a required JetStream API level in request methods, allowing clients to assert that the server supports a minimum API version for certain operations. The main changes involve adding an apiLevel parameter to relevant methods, implementing the NatsJSApiLevel struct, and ensuring the appropriate request headers are set. Most usages default to no required API level for backward compatibility.

JetStream API Level Support

  • Added a new NatsJSApiLevel struct in NatsJSApiLevel.cs to represent JetStream API levels and provide header value generation.
  • Updated all JetStream request methods (e.g., JSRequestResponseAsync, JSRequestAsync, and related consumer/stream methods) to accept an optional apiLevel parameter, defaulting to no required level. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29]
  • Modified request logic to include the Nats-Required-Api-Level header when an API level is set, ensuring the server is aware of the client's requirements. [1] [2] [3]

Codebase Maintenance

  • Removed an unused internal import in NatsObjStore.cs for code cleanliness.

These changes collectively improve the library's ability to interact safely with JetStream servers of varying API levels and help future-proof client-server communication.

@mtmk mtmk requested a review from Copilot September 11, 2025 09:49
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 pull request introduces JetStream API level support to ensure compatible client-server communication. It adds the ability for clients to specify minimum API level requirements when making JetStream requests, allowing servers to validate compatibility and return appropriate errors when requirements are not met.

  • Added NatsJSApiLevel struct to represent and manage API level values
  • Updated all JetStream request methods to accept an optional apiLevel parameter
  • Modified request logic to include the Nats-Required-Api-Level header when API levels are specified

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/NATS.Client.JetStream/NatsJSApiLevel.cs New struct defining API level constants and header management
src/NATS.Client.JetStream/NatsJSContext.cs Core request methods updated with API level parameter and header logic
src/NATS.Client.JetStream/NatsJSContext.Streams.cs Stream management methods updated with API level parameter
src/NATS.Client.JetStream/NatsJSContext.Consumers.cs Consumer management methods updated with API level parameter
src/NATS.Client.JetStream/NatsJSConsumer.cs Consumer refresh method updated with API level parameter
src/NATS.Client.JetStream/NatsJSStream.cs Stream refresh and get methods updated with API level parameter
src/NATS.Client.JetStream/INatsJSContext.cs Interface updated with API level parameter
src/NATS.Client.KeyValueStore/NatsKVContext.cs Key-value store methods updated with API level parameter
src/NATS.Client.ObjectStore/NatsObjStore.cs Object store methods updated with API level parameter; removed unused import
tests/NATS.Client.JetStream.Tests/JetStreamTest.cs Added comprehensive API level enforcement test
tests/NATS.Client.JetStream.Tests/JetStreamApiSerializerTest.cs Updated test method with API level parameter
tests/NATS.Client.KeyValueStore.Tests/KeyValueStoreTest.cs Updated test method with explicit API level parameter
tests/NATS.Client.ObjectStore.Tests/NatsObjContextFactoryTest.cs Updated mock method signature
tests/NATS.Client.KeyValueStore.Tests/NatsKVContextFactoryTest.cs Updated mock method signature

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@mtmk mtmk marked this pull request as ready for review September 11, 2025 09:50
@mtmk mtmk requested a review from scottf September 11, 2025 09:51
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 marked this pull request as draft September 12, 2025 06:54
@mtmk mtmk added the testing label Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants