-
Notifications
You must be signed in to change notification settings - Fork 40
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
Headers parsing #63
Merged
Merged
Headers parsing #63
Changes from 6 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f657140
WIP: Headers parsing
mtmk 17902ea
Headers tests
mtmk 6830c7d
Handle empty headers
mtmk 3f60bf2
Update licence information
mtmk 053330f
Update licence information
mtmk 0a7feb4
Moved HeaderParser to connection
mtmk 799cec8
Fixed cluster reconnect tests
mtmk fcd2953
Bumped up the test timeout to 10 minutes
mtmk 58ee4b2
WIP: Investigating GitHub test runner
mtmk 76b4121
WIP: Investigating GitHub test runner
mtmk 6b74a6a
Fixing tests
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 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 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,6 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ASCII/@EntryIndexedValue">ASCII</s:String> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CR/@EntryIndexedValue">CR</s:String> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LF/@EntryIndexedValue">LF</s:String> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=HMSG/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=HPUB/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
14 changes: 14 additions & 0 deletions
14
sandbox/Example.Core.PublishHeaders/Example.Core.PublishHeaders.csproj
This file contains 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,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains 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,31 @@ | ||
// > nats sub bar.* | ||
using Microsoft.Extensions.Logging; | ||
using NATS.Client.Core; | ||
|
||
var subject = "bar.xyz"; | ||
var options = NatsOptions.Default with { LoggerFactory = new MinimumConsoleLoggerFactory(LogLevel.Error) }; | ||
|
||
Print("[CON] Connecting...\n"); | ||
|
||
await using var connection = new NatsConnection(options); | ||
|
||
for (int i = 0; i < 10; i++) | ||
{ | ||
Print($"[PUB] Publishing to subject ({i}) '{subject}'...\n"); | ||
await connection.PublishAsync<Bar>( | ||
subject, | ||
new Bar { Id = i, Name = "Baz" }, | ||
new NatsPubOpts { Headers = new NatsHeaders { ["XFoo"] = $"bar{i}" } }); | ||
} | ||
|
||
void Print(string message) | ||
{ | ||
Console.Write($"{DateTime.Now:HH:mm:ss} {message}"); | ||
} | ||
|
||
public record Bar | ||
{ | ||
public int Id { get; set; } | ||
|
||
public string? Name { get; set; } | ||
} |
14 changes: 14 additions & 0 deletions
14
sandbox/Example.Core.SubscribeHeaders/Example.Core.SubscribeHeaders.csproj
This file contains 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,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\NATS.Client.Core\NATS.Client.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains 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,41 @@ | ||
// > nats pub bar.xyz --count=10 "my_message_{{ Count }}" -H X-Foo:Baz | ||
|
||
using System.Text; | ||
using Microsoft.Extensions.Logging; | ||
using NATS.Client.Core; | ||
|
||
var subject = "bar.*"; | ||
var options = NatsOptions.Default with { LoggerFactory = new MinimumConsoleLoggerFactory(LogLevel.Error) }; | ||
|
||
Print("[CON] Connecting...\n"); | ||
|
||
await using var connection = new NatsConnection(options); | ||
|
||
Print($"[SUB] Subscribing to subject '{subject}'...\n"); | ||
|
||
NatsSub sub = await connection.SubscribeAsync(subject); | ||
|
||
await foreach (var msg in sub.Msgs.ReadAllAsync()) | ||
{ | ||
Print($"[RCV] {msg.Subject}: {Encoding.UTF8.GetString(msg.Data.Span)}\n"); | ||
if (msg.Headers != null) | ||
{ | ||
foreach (var (key, values) in msg.Headers) | ||
{ | ||
foreach (var value in values) | ||
Print($" {key}: {value}\n"); | ||
} | ||
} | ||
} | ||
|
||
void Print(string message) | ||
{ | ||
Console.Write($"{DateTime.Now:HH:mm:ss} {message}"); | ||
} | ||
|
||
public record Bar | ||
{ | ||
public int Id { get; set; } | ||
|
||
public string? Name { get; set; } | ||
} |
This file contains 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 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
Oops, something went wrong.
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.
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.
Removed precalculated
offset +=...
code since BufferWriter.Advance() method (which also marked with AggressiveInlining) does just that anyway and makes it much easier comprehend.