Skip to content

Commit

Permalink
try cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Mar 29, 2022
1 parent 86ed2fe commit 3fcc033
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 48 deletions.
47 changes: 1 addition & 46 deletions sandbox/ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();


}

Expand Down
9 changes: 7 additions & 2 deletions src/AlterNats/NatsConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public NatsConnection(NatsOptions options)
{
socket.DualMode = true;
}

socket.NoDelay = true;
socket.SendBufferSize = 0;
socket.ReceiveBufferSize = 0;
Expand Down Expand Up @@ -95,7 +95,12 @@ public async ValueTask ReconnectAsync()
{
ConnectionState = NatsConnectionState.Reconnecting;

throw new NotImplementedException();
// Cleanup

// Resubscribe




}

Expand Down
4 changes: 4 additions & 0 deletions tools/cluster-seed.bat
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions tools/cluster-server-b.bat
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions tools/cluster-server-c.bat
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3fcc033

Please sign in to comment.