feat: port session 05 — Subscription Index (sublist)
Port trie-based subject matching engine (81 features, 74 tests). Includes SubscriptionIndex with cache, wildcard matching (*/>), queue subscription groups, reverse match, notifications, stats, and subject validation utilities. Also adds minimal Subscription and NatsClient stubs needed by the index.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
77
dotnet/src/ZB.MOM.NatsNet.Server/Internal/Subscription.cs
Normal file
77
dotnet/src/ZB.MOM.NatsNet.Server/Internal/Subscription.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
// Copyright 2012-2025 The NATS Authors
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Adapted from server/client.go (subscription struct) in the NATS server Go source.
|
||||
|
||||
namespace ZB.MOM.NatsNet.Server.Internal;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a client subscription in the NATS server.
|
||||
/// Mirrors the Go <c>subscription</c> struct from client.go.
|
||||
/// This is a minimal stub; full client integration will be added in later sessions.
|
||||
/// </summary>
|
||||
public sealed class Subscription
|
||||
{
|
||||
/// <summary>The subject this subscription is listening on.</summary>
|
||||
public byte[] Subject { get; set; } = [];
|
||||
|
||||
/// <summary>The queue group name, or null/empty for non-queue subscriptions.</summary>
|
||||
public byte[]? Queue { get; set; }
|
||||
|
||||
/// <summary>The subscription identifier.</summary>
|
||||
public byte[]? Sid { get; set; }
|
||||
|
||||
/// <summary>Queue weight for remote queue subscriptions.</summary>
|
||||
public int Qw;
|
||||
|
||||
/// <summary>Closed flag (0 = open, 1 = closed).</summary>
|
||||
private int _closed;
|
||||
|
||||
/// <summary>The client that owns this subscription. Null in test/stub scenarios.</summary>
|
||||
public NatsClient? Client { get; set; }
|
||||
|
||||
/// <summary>Marks this subscription as closed.</summary>
|
||||
public void Close() => Interlocked.Exchange(ref _closed, 1);
|
||||
|
||||
/// <summary>Returns true if this subscription has been closed.</summary>
|
||||
public bool IsClosed() => Interlocked.CompareExchange(ref _closed, 0, 0) == 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the kind of client connection.
|
||||
/// Mirrors Go's <c>clientKind</c> enum.
|
||||
/// This is a minimal stub; full implementation in later sessions.
|
||||
/// </summary>
|
||||
public enum ClientKind
|
||||
{
|
||||
Client = 0,
|
||||
Router = 1,
|
||||
Gateway = 2,
|
||||
System = 3,
|
||||
Leaf = 4,
|
||||
JetStream = 5,
|
||||
Account = 6,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Minimal client stub for subscription routing.
|
||||
/// Full implementation will be added in later sessions.
|
||||
/// </summary>
|
||||
public class NatsClient
|
||||
{
|
||||
/// <summary>The kind of client connection.</summary>
|
||||
public ClientKind Kind { get; set; }
|
||||
|
||||
/// <summary>Whether this is a hub leaf node. Stub for now.</summary>
|
||||
public virtual bool IsHubLeafNode() => false;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
BIN
porting.db
BIN
porting.db
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
# NATS .NET Porting Status Report
|
||||
|
||||
Generated: 2026-02-26 16:54:25 UTC
|
||||
Generated: 2026-02-26 17:11:07 UTC
|
||||
|
||||
## Modules (12 total)
|
||||
|
||||
@@ -13,18 +13,18 @@ Generated: 2026-02-26 16:54:25 UTC
|
||||
|
||||
| Status | Count |
|
||||
|--------|-------|
|
||||
| complete | 368 |
|
||||
| complete | 449 |
|
||||
| n_a | 82 |
|
||||
| not_started | 3155 |
|
||||
| not_started | 3074 |
|
||||
| stub | 68 |
|
||||
|
||||
## Unit Tests (3257 total)
|
||||
|
||||
| Status | Count |
|
||||
|--------|-------|
|
||||
| complete | 155 |
|
||||
| n_a | 50 |
|
||||
| not_started | 2953 |
|
||||
| complete | 219 |
|
||||
| n_a | 82 |
|
||||
| not_started | 2857 |
|
||||
| stub | 99 |
|
||||
|
||||
## Library Mappings (36 total)
|
||||
@@ -36,4 +36,4 @@ Generated: 2026-02-26 16:54:25 UTC
|
||||
|
||||
## Overall Progress
|
||||
|
||||
**666/6942 items complete (9.6%)**
|
||||
**843/6942 items complete (12.1%)**
|
||||
|
||||
39
reports/report_b8f2f66.md
Normal file
39
reports/report_b8f2f66.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# NATS .NET Porting Status Report
|
||||
|
||||
Generated: 2026-02-26 17:11:07 UTC
|
||||
|
||||
## Modules (12 total)
|
||||
|
||||
| Status | Count |
|
||||
|--------|-------|
|
||||
| complete | 11 |
|
||||
| not_started | 1 |
|
||||
|
||||
## Features (3673 total)
|
||||
|
||||
| Status | Count |
|
||||
|--------|-------|
|
||||
| complete | 449 |
|
||||
| n_a | 82 |
|
||||
| not_started | 3074 |
|
||||
| stub | 68 |
|
||||
|
||||
## Unit Tests (3257 total)
|
||||
|
||||
| Status | Count |
|
||||
|--------|-------|
|
||||
| complete | 219 |
|
||||
| n_a | 82 |
|
||||
| not_started | 2857 |
|
||||
| stub | 99 |
|
||||
|
||||
## Library Mappings (36 total)
|
||||
|
||||
| Status | Count |
|
||||
|--------|-------|
|
||||
| mapped | 36 |
|
||||
|
||||
|
||||
## Overall Progress
|
||||
|
||||
**843/6942 items complete (12.1%)**
|
||||
Reference in New Issue
Block a user