diff --git a/sandbox/ConsoleApp1/ConsoleApp1.csproj b/sandbox/ConsoleApp1/ConsoleApp1.csproj deleted file mode 100644 index f6dc3f6fe..000000000 --- a/sandbox/ConsoleApp1/ConsoleApp1.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - Exe - net6.0 - enable - enable - - - - - - - diff --git a/sandbox/ConsoleApp1/Program.cs b/sandbox/ConsoleApp1/Program.cs deleted file mode 100644 index 705bde39d..000000000 --- a/sandbox/ConsoleApp1/Program.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Diagnostics; -using NATS.Client.Core; - -// await using - var conn = new NatsConnection(); - -int msgCount = 100_000; -CountdownEvent latch = new CountdownEvent(msgCount); - -var subscription = await conn.SubscribeAsync("foo", x => -{ - try - { - Console.WriteLine($"Received {x}"); - latch.Signal(); - } - catch (Exception e) - { - Console.WriteLine(e.Message); - } -}); - -Stopwatch sw = Stopwatch.StartNew(); - -// publish -for (int x = 0; x < msgCount; x++) -{ -#pragma warning disable CS4014 - conn.PublishAsync("foo", new Record(x)); -#pragma warning restore CS4014 -} -sw.Stop(); -latch.Wait(); - - Console.WriteLine("TIME " + sw.ElapsedMilliseconds); - -public record Record(int id); -public record NotRecord(String id); diff --git a/sandbox/ConsoleApp2/ConsoleApp2.csproj b/sandbox/ConsoleApp2/ConsoleApp2.csproj deleted file mode 100644 index 9411d850b..000000000 --- a/sandbox/ConsoleApp2/ConsoleApp2.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - Exe - net6.0 - enable - enable - false - - - - - - - diff --git a/sandbox/ConsoleApp2/Program.cs b/sandbox/ConsoleApp2/Program.cs deleted file mode 100644 index 443a24dc3..000000000 --- a/sandbox/ConsoleApp2/Program.cs +++ /dev/null @@ -1,76 +0,0 @@ -using NATS.Client.Core; -#pragma warning disable CS4014 - -var natsKey1 = new NatsKey("subject1"); -var natsKey2 = new NatsKey("subject2"); - -await using var subConnection1 = new NatsConnection(NatsOpts.Default with -{ - Url = "localhost:4222" -}); -await subConnection1.ConnectAsync(); - -using var d1 = await subConnection1.SubscribeAsync(natsKey1, x => -{ - Console.WriteLine($"\tSUB1:{x}"); -}); - -using var d1n = await subConnection1.SubscribeAsync(natsKey2, x => -{ - Console.WriteLine($"\tSUB1:{x}"); -}); - -await using var subConnection2 = new NatsConnection(NatsOpts.Default with -{ - Url = "localhost:4222" -}); - -await subConnection2.ConnectAsync(); - -using var d2 = await subConnection2.SubscribeAsync(natsKey1, x => -{ - Console.WriteLine($"\tSUB2:{x}"); -}); - -using var d2n = await subConnection2.SubscribeAsync(natsKey2, x => -{ - Console.WriteLine($"\tSUB2:{x}"); -}); - -var cts = new CancellationTokenSource(); - -Task.Run(async () => -{ - await using var pubConnection1 = new NatsConnection(NatsOpts.Default with - { - Url = "localhost:4222" - }); - - await pubConnection1.ConnectAsync(); - - await using var pubConnection2 = new NatsConnection(NatsOpts.Default with - { - Url = "localhost:4222" - }); - - await pubConnection2.ConnectAsync(); - - var random = new Random(); - while (!cts.IsCancellationRequested) - { - var time = DateTime.Now.ToString(); - pubConnection1.PublishAsync(natsKey1, time); - Console.WriteLine($"PUB1:{time}"); - - var number = random.Next(0, 1000); - pubConnection2.PublishAsync(natsKey2, number); - Console.WriteLine($"PUB2:{number}"); - - await Task.Delay(1000, cts.Token); - } -}, cts.Token); - -Console.ReadKey(); -cts.Cancel(); - -Console.WriteLine("end"); diff --git a/sandbox/Example.JetStream.PullConsumer/Example.JetStream.PullConsumer.csproj b/sandbox/Example.JetStream.PullConsumer/Example.JetStream.PullConsumer.csproj index c66fda896..17f60cc21 100644 --- a/sandbox/Example.JetStream.PullConsumer/Example.JetStream.PullConsumer.csproj +++ b/sandbox/Example.JetStream.PullConsumer/Example.JetStream.PullConsumer.csproj @@ -5,6 +5,7 @@ net6.0 enable enable + false diff --git a/tests/NATS.Client.JetStream.Tests/ConsumerConsumeTest.cs b/tests/NATS.Client.JetStream.Tests/ConsumerConsumeTest.cs index 2e0446141..c4a2d3388 100644 --- a/tests/NATS.Client.JetStream.Tests/ConsumerConsumeTest.cs +++ b/tests/NATS.Client.JetStream.Tests/ConsumerConsumeTest.cs @@ -1,3 +1,4 @@ +using System.Text.RegularExpressions; using NATS.Client.Core.Tests; namespace NATS.Client.JetStream.Tests; @@ -64,13 +65,12 @@ await Retry.Until( .Where(f => f.Message.StartsWith("PUB $JS.API.CONSUMER.MSG.NEXT.s1.c1")) .ToList(); - // Initial pull - Assert.Matches(@"^PUB.*""batch"":10\b", msgNextRequests.First().Message); - - foreach (var frame in msgNextRequests.Skip(1)) + foreach (var frame in msgNextRequests) { - // Consequent pulls should top-up to max value - Assert.Matches(@"^PUB.*""batch"":5\b", frame.Message); + var match = Regex.Match(frame.Message, @"^PUB.*""batch"":(\d+)"); + Assert.True(match.Success); + var batch = int.Parse(match.Groups[1].Value); + Assert.True(batch <= 10); } } diff --git a/tests/NATS.Client.Perf/NATS.Client.Perf.csproj b/tests/NATS.Client.Perf/NATS.Client.Perf.csproj index 354686873..0aad01866 100644 --- a/tests/NATS.Client.Perf/NATS.Client.Perf.csproj +++ b/tests/NATS.Client.Perf/NATS.Client.Perf.csproj @@ -5,6 +5,7 @@ net6.0 enable enable + false