feat(batch34): implement and verify group C cluster consumer features

This commit is contained in:
Joseph Doherty
2026-02-28 23:40:41 -05:00
parent 9a42b93b4b
commit 91627ecefb
4 changed files with 324 additions and 0 deletions
@@ -87,4 +87,144 @@ public sealed partial class NatsServer
cluster.TrackInflightStreamProposal(account.Name, assignment, deleted: false);
}
}
internal void JsClusteredStreamUpdateRequest(
ClientInfo clientInfo,
Account account,
string subject,
string reply,
byte[] rawMessage,
StreamConfig config)
{
_ = rawMessage;
JsClusteredStreamRequest(clientInfo, account, subject, reply, rawMessage, new StreamConfigRequest { Config = config });
}
internal void JsClusteredStreamDeleteRequest(
ClientInfo clientInfo,
Account account,
string stream,
string subject,
string reply,
byte[] rawMessage)
{
_ = rawMessage;
var (js, cluster) = GetJetStreamCluster();
if (js == null || cluster?.Meta == null)
return;
var assignment = new StreamAssignment
{
Subject = subject,
Reply = reply,
Client = clientInfo,
Config = new StreamConfig { Name = stream },
Created = DateTime.UtcNow,
};
cluster.Meta.Propose(Encoding.UTF8.GetBytes($"delete-stream:{account.Name}:{stream}"));
cluster.TrackInflightStreamProposal(account.Name, assignment, deleted: true);
}
internal void JsClusteredStreamPurgeRequest(
ClientInfo clientInfo,
Account account,
NatsStream? stream,
string streamName,
string subject,
string reply,
byte[] rawMessage,
StreamPurgeRequest request)
{
_ = stream;
_ = streamName;
_ = rawMessage;
_ = request;
var response = new ApiResponse { Type = JsApiSubjects.JsApiStreamPurgeResponseType };
SendAPIResponse(clientInfo, account, subject, reply, string.Empty, JsonResponse(response));
}
internal void JsClusteredStreamRestoreRequest(
ClientInfo clientInfo,
Account account,
object request,
string subject,
string reply,
byte[] rawMessage)
{
_ = request;
_ = rawMessage;
var response = new ApiResponse { Type = JsApiSubjects.JsApiStreamRestoreResponseType };
SendAPIResponse(clientInfo, account, subject, reply, string.Empty, JsonResponse(response));
}
internal bool AllPeersOffline(RaftGroup? group)
{
if (group == null || group.Peers.Length == 0)
return false;
foreach (var peer in group.Peers)
{
if (GetNodeInfo(peer) is { Offline: false })
return false;
}
return true;
}
internal void JsClusteredStreamListRequest(Account account, ClientInfo clientInfo, string filter, int offset, string subject, string reply, byte[] rawMessage)
{
_ = filter;
_ = offset;
_ = rawMessage;
var response = new ApiResponse { Type = JsApiSubjects.JsApiStreamListResponseType };
SendAPIResponse(clientInfo, account, subject, reply, string.Empty, JsonResponse(response));
}
internal void JsClusteredConsumerListRequest(Account account, ClientInfo clientInfo, int offset, string stream, string subject, string reply, byte[] rawMessage)
{
_ = offset;
_ = stream;
_ = rawMessage;
var response = new ApiResponse { Type = JsApiSubjects.JsApiConsumerListResponseType };
SendAPIResponse(clientInfo, account, subject, reply, string.Empty, JsonResponse(response));
}
internal void JsClusteredConsumerDeleteRequest(
ClientInfo clientInfo,
Account account,
string stream,
string consumer,
string subject,
string reply,
byte[] rawMessage)
{
_ = rawMessage;
var (js, cluster) = GetJetStreamCluster();
if (js == null || cluster?.Meta == null)
return;
cluster.Meta.Propose(Encoding.UTF8.GetBytes($"delete-consumer:{account.Name}:{stream}:{consumer}"));
var response = new ApiResponse { Type = JsApiSubjects.JsApiConsumerDeleteResponseType };
SendAPIResponse(clientInfo, account, subject, reply, string.Empty, JsonResponse(response));
}
internal void JsClusteredMsgDeleteRequest(
ClientInfo clientInfo,
Account account,
NatsStream? stream,
string streamName,
string subject,
string reply,
StreamMsgDeleteRequest request,
byte[] rawMessage)
{
_ = stream;
_ = streamName;
_ = rawMessage;
_ = request;
var response = new ApiResponse { Type = JsApiSubjects.JsApiMsgDeleteResponseType };
SendAPIResponse(clientInfo, account, subject, reply, string.Empty, JsonResponse(response));
}
}