-
Couldn't load subscription status.
- Fork 84
Add JetStream calls API Level support #946
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
base: release/2.7
Are you sure you want to change the base?
Conversation
# Conflicts: # tests/NATS.Client.TestUtilities/Utils.cs
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 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
NatsJSApiLevelstruct to represent and manage API level values - Updated all JetStream request methods to accept an optional
apiLevelparameter - Modified request logic to include the
Nats-Required-Api-Levelheader 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.
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
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
apiLevelparameter to relevant methods, implementing theNatsJSApiLevelstruct, and ensuring the appropriate request headers are set. Most usages default to no required API level for backward compatibility.JetStream API Level Support
NatsJSApiLevelstruct inNatsJSApiLevel.csto represent JetStream API levels and provide header value generation.JSRequestResponseAsync,JSRequestAsync, and related consumer/stream methods) to accept an optionalapiLevelparameter, 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]Nats-Required-Api-Levelheader when an API level is set, ensuring the server is aware of the client's requirements. [1] [2] [3]Codebase Maintenance
NatsObjStore.csfor 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.