perf: pool SubList match builders and cleanup scans
This commit is contained in:
@@ -208,6 +208,50 @@ public class RouteSubscriptionTests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Removing_one_subject_keeps_other_remote_interest_intact()
|
||||
{
|
||||
var cluster = Guid.NewGuid().ToString("N");
|
||||
var a = await StartServerAsync(MakeClusterOpts(cluster));
|
||||
var b = await StartServerAsync(MakeClusterOpts(cluster, a.Server.ClusterListen!));
|
||||
|
||||
try
|
||||
{
|
||||
await WaitForRouteFormation(a.Server, b.Server);
|
||||
|
||||
await using var nc = new NatsConnection(new NatsOpts
|
||||
{
|
||||
Url = $"nats://127.0.0.1:{a.Server.Port}",
|
||||
});
|
||||
await nc.ConnectAsync();
|
||||
|
||||
await using var sub1 = await nc.SubscribeCoreAsync<string>("multi.one");
|
||||
await using var sub2 = await nc.SubscribeCoreAsync<string>("multi.two");
|
||||
await nc.PingAsync();
|
||||
|
||||
await WaitForCondition(() => b.Server.HasRemoteInterest("multi.one") && b.Server.HasRemoteInterest("multi.two"));
|
||||
b.Server.HasRemoteInterest("multi.one").ShouldBeTrue();
|
||||
b.Server.HasRemoteInterest("multi.two").ShouldBeTrue();
|
||||
|
||||
await sub1.DisposeAsync();
|
||||
await nc.PingAsync();
|
||||
|
||||
await WaitForCondition(() => !b.Server.HasRemoteInterest("multi.one"));
|
||||
b.Server.HasRemoteInterest("multi.one").ShouldBeFalse();
|
||||
b.Server.HasRemoteInterest("multi.two").ShouldBeTrue();
|
||||
|
||||
await sub2.DisposeAsync();
|
||||
await nc.PingAsync();
|
||||
|
||||
await WaitForCondition(() => !b.Server.HasRemoteInterest("multi.two"));
|
||||
b.Server.HasRemoteInterest("multi.two").ShouldBeFalse();
|
||||
}
|
||||
finally
|
||||
{
|
||||
await DisposeServers(a, b);
|
||||
}
|
||||
}
|
||||
|
||||
// Go: RS+ wire protocol parsing (low-level)
|
||||
[Fact]
|
||||
public async Task RSplus_frame_registers_remote_interest_via_wire()
|
||||
|
||||
@@ -45,4 +45,20 @@ public class SubListAllocationGuardTests
|
||||
matches.Count.ShouldBe(4);
|
||||
matches.ShouldAllBe(match => match.Queue == "workers");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Match_merges_queue_groups_from_multiple_matching_nodes_by_queue_name()
|
||||
{
|
||||
using var sl = new SubList();
|
||||
sl.Insert(new Subscription { Subject = "orders.created", Queue = "workers", Sid = "1" });
|
||||
sl.Insert(new Subscription { Subject = "orders.*", Queue = "workers", Sid = "2" });
|
||||
sl.Insert(new Subscription { Subject = "orders.>", Queue = "audit", Sid = "3" });
|
||||
|
||||
var result = sl.Match("orders.created");
|
||||
|
||||
result.PlainSubs.ShouldBeEmpty();
|
||||
result.QueueSubs.Length.ShouldBe(2);
|
||||
result.QueueSubs.Single(group => group[0].Queue == "workers").Length.ShouldBe(2);
|
||||
result.QueueSubs.Single(group => group[0].Queue == "audit").Length.ShouldBe(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user