From 3fcc03301e05424d20716f28da676a59b7e7e1ad Mon Sep 17 00:00:00 2001 From: neuecc Date: Wed, 30 Mar 2022 08:14:50 +0900 Subject: [PATCH] try cluster --- sandbox/ConsoleApp/Program.cs | 47 +-------------------------------- src/AlterNats/NatsConnection.cs | 9 +++++-- tools/cluster-seed.bat | 4 +++ tools/cluster-server-b.bat | 4 +++ tools/cluster-server-c.bat | 4 +++ 5 files changed, 20 insertions(+), 48 deletions(-) create mode 100644 tools/cluster-seed.bat create mode 100644 tools/cluster-server-b.bat create mode 100644 tools/cluster-server-c.bat diff --git a/sandbox/ConsoleApp/Program.cs b/sandbox/ConsoleApp/Program.cs index 1b673adbf..91ad260ca 100644 --- a/sandbox/ConsoleApp/Program.cs +++ b/sandbox/ConsoleApp/Program.cs @@ -32,52 +32,7 @@ public static async Task Main() var connection1 = new NatsConnection(options); await connection1.ConnectAsync(); - var connection2 = new NatsConnection(options); - await connection2.ConnectAsync(); - - var connection3 = new NatsConnection(options); - await connection3.ConnectAsync(); - - var key = new NatsKey("foobar"); - var q = new NatsKey("qqq"); - - - //await connection1.SubscribeAsync(key, q, (int x) => - //{ - // Console.WriteLine("ONE:" + x); - //}); - - //await connection2.SubscribeAsync(key, q, (int x) => - //{ - // Console.WriteLine("TWO:" + x); - //}); - - //for (int i = 0; i < 200; i++) - //{ - // await connection3.PublishAsync(key, i); - //} - - - await connection1.SubscribeAsync(key.Key, (int x) => - { - Console.WriteLine(x); - }); - - await connection2.PublishBatchAsync(new[] - { - ("foobar", 100), - ("foobar", 101), - ("foobar", 102), - ("foobar", 103), - ("foobar", 104), - }); - - var bytes = new byte[] { 1, 20, 255 }; - await connection1.PublishAsync("foo", bytes); - - - - Console.ReadLine(); + } diff --git a/src/AlterNats/NatsConnection.cs b/src/AlterNats/NatsConnection.cs index 7d428488b..fc8faca33 100644 --- a/src/AlterNats/NatsConnection.cs +++ b/src/AlterNats/NatsConnection.cs @@ -51,7 +51,7 @@ public NatsConnection(NatsOptions options) { socket.DualMode = true; } - + socket.NoDelay = true; socket.SendBufferSize = 0; socket.ReceiveBufferSize = 0; @@ -95,7 +95,12 @@ public async ValueTask ReconnectAsync() { ConnectionState = NatsConnectionState.Reconnecting; - throw new NotImplementedException(); + // Cleanup + + // Resubscribe + + + } diff --git a/tools/cluster-seed.bat b/tools/cluster-seed.bat new file mode 100644 index 000000000..c5045f1d5 --- /dev/null +++ b/tools/cluster-seed.bat @@ -0,0 +1,4 @@ +@REM https://docs.nats.io/running-a-nats-service/introduction/flags +@REM -DV is Debug and Protocol Trace +@REM -DVV is Debug and Verbose +nats-server.exe -D -p 4222 -cluster nats://localhost:4248 --cluster_name test-cluster \ No newline at end of file diff --git a/tools/cluster-server-b.bat b/tools/cluster-server-b.bat new file mode 100644 index 000000000..6582d0360 --- /dev/null +++ b/tools/cluster-server-b.bat @@ -0,0 +1,4 @@ +@REM https://docs.nats.io/running-a-nats-service/introduction/flags +@REM -DV is Debug and Protocol Trace +@REM -DVV is Debug and Verbose +nats-server.exe -D -p 5248 -cluster nats://localhost:5248 -routes nats://localhost:4248 --cluster_name test-cluster \ No newline at end of file diff --git a/tools/cluster-server-c.bat b/tools/cluster-server-c.bat new file mode 100644 index 000000000..f59983a8c --- /dev/null +++ b/tools/cluster-server-c.bat @@ -0,0 +1,4 @@ +@REM https://docs.nats.io/running-a-nats-service/introduction/flags +@REM -DV is Debug and Protocol Trace +@REM -DVV is Debug and Verbose +nats-server.exe -D -p 6222 -cluster nats://localhost:6248 -routes nats://localhost:4248 --cluster_name test-cluster \ No newline at end of file