feat: implement jetstream governance runtime parity semantics
This commit is contained in:
@@ -7,6 +7,8 @@ public sealed class JetStreamMetaGroup
|
||||
{
|
||||
private readonly int _nodes;
|
||||
private readonly ConcurrentDictionary<string, byte> _streams = new(StringComparer.Ordinal);
|
||||
private int _leaderIndex = 1;
|
||||
private long _leadershipVersion = 1;
|
||||
|
||||
public JetStreamMetaGroup(int nodes)
|
||||
{
|
||||
@@ -25,13 +27,18 @@ public sealed class JetStreamMetaGroup
|
||||
{
|
||||
Streams = _streams.Keys.OrderBy(x => x, StringComparer.Ordinal).ToArray(),
|
||||
ClusterSize = _nodes,
|
||||
LeaderId = $"meta-{_leaderIndex}",
|
||||
LeadershipVersion = _leadershipVersion,
|
||||
};
|
||||
}
|
||||
|
||||
public void StepDown()
|
||||
{
|
||||
// Placeholder for parity API behavior; current in-memory meta group
|
||||
// does not track explicit leader state.
|
||||
_leaderIndex++;
|
||||
if (_leaderIndex > Math.Max(_nodes, 1))
|
||||
_leaderIndex = 1;
|
||||
|
||||
Interlocked.Increment(ref _leadershipVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,4 +46,6 @@ public sealed class MetaGroupState
|
||||
{
|
||||
public IReadOnlyList<string> Streams { get; init; } = [];
|
||||
public int ClusterSize { get; init; }
|
||||
public string LeaderId { get; init; } = string.Empty;
|
||||
public long LeadershipVersion { get; init; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user