-
Notifications
You must be signed in to change notification settings - Fork 102
Add flags to NatsMsg and JetStream Request #652
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4b231fc
Add flags to NatsMsg
mtmk d8c80f9
Code comments for msg size
mtmk be0334f
Format
mtmk dfa7d03
Fix warnings
mtmk d68ec5b
Keep 503 header
mtmk 93c3ab7
Format
mtmk a4517e0
JetStream TryJSRequestAsync
mtmk 2f8e90e
Format
mtmk a64fd08
Fix tests
mtmk 71ed9d9
Refactor JetStream method results to use NatsResult
mtmk 7e5b699
Refactor NatsMsg size and flags handling in tests and class
mtmk 643e3d5
Refactor JSON document deserialization
mtmk 2f9e815
Refactor NatsJSContext error handling logic.
mtmk 429f665
Merge branch 'main' into nats-msg-flags
mtmk 6a47672
Fix memory leak by disposing JsonDocument properly
mtmk c335751
Skip slow tests for unique NUID generation
mtmk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| using System.Runtime.CompilerServices; | ||
|
|
||
| namespace NATS.Client.Core; | ||
|
|
||
| public readonly struct NatsResult<T> | ||
| { | ||
| private readonly T? _value; | ||
| private readonly Exception? _error; | ||
|
|
||
| public NatsResult(T value) | ||
| { | ||
| _value = value; | ||
| _error = null; | ||
| } | ||
|
|
||
| public NatsResult(Exception error) | ||
| { | ||
| _value = default; | ||
| _error = error; | ||
| } | ||
|
|
||
| public T Value => _value ?? ThrowValueIsNotSetException(); | ||
|
|
||
| public Exception Error => _error ?? ThrowErrorIsNotSetException(); | ||
|
|
||
| public bool Success => _error == null; | ||
|
|
||
| public static implicit operator NatsResult<T>(T value) => new(value); | ||
|
|
||
| public static implicit operator NatsResult<T>(Exception error) => new(error); | ||
|
|
||
| private static T ThrowValueIsNotSetException() => throw CreateInvalidOperationException("Result value is not set"); | ||
|
|
||
| private static Exception ThrowErrorIsNotSetException() => throw CreateInvalidOperationException("Result error is not set"); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| private static Exception CreateInvalidOperationException(string message) => new InvalidOperationException(message); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
src/NATS.Client.JetStream/Internal/NatsJSErrorAwareJsonSerializer.cs
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/NATS.Client.JetStream/Internal/NatsJSJsonDocumentSerializer.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| using System.Buffers; | ||
| using System.Text.Json; | ||
| using NATS.Client.Core; | ||
|
|
||
| namespace NATS.Client.JetStream.Internal; | ||
|
|
||
| internal sealed class NatsJSJsonDocumentSerializer : INatsDeserialize<JsonDocument> | ||
| { | ||
| public static readonly NatsJSJsonDocumentSerializer Default = new(); | ||
|
|
||
| public JsonDocument? Deserialize(in ReadOnlySequence<byte> buffer) => buffer.Length == 0 ? default : JsonDocument.Parse(buffer); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.