-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementations of HPUB and HMSG messages. Also includes minor code clean-up and some test improvements to reduce false positives. * WIP: Headers parsing * Headers tests * Handle empty headers * Update licence information Co-authored-by: Caleb Lloyd <2414837+caleblloyd@users.noreply.github.com> * Update licence information Co-authored-by: Caleb Lloyd <2414837+caleblloyd@users.noreply.github.com> * Moved HeaderParser to connection Also, test resilience improvements. * Fixed cluster reconnect tests This was caused by recent nats-server fix. * Bumped up the test timeout to 10 minutes GitHub CI seems to have slowed down!? On my local ubuntu vm runs under a minute. * WIP: Investigating GitHub test runner * WIP: Investigating GitHub test runner * Fixing tests Separated server version read. --------- Co-authored-by: Caleb Lloyd <2414837+caleblloyd@users.noreply.github.com>
- Loading branch information
1 parent
e5cd29e
commit 7d0ecad
Showing
39 changed files
with
1,600 additions
and
688 deletions.
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.