11cc6715ed
Adds the session-less alarm CLI subcommands. stream-alarms attaches to the gateway's central alarm feed (--filter-prefix, --max-events, --json/--jsonl); acknowledge-alarm is a unary ack (--reference required, --comment, --operator). StreamAlarmsAsync joins QueryActiveAlarmsAsync on MxGatewayClient and the transport interface; the CLI client interface, adapter, and FakeGatewayTransport follow. Also fixes the OCE bug exposed by -VerifyWrite in the cross-language e2e: StreamEventsAsync's await foreach now swallows OperationCanceledException when the supplied cancellation token is the one that fired (graceful end-of-window), and RunBatchAsync no longer excludes OCE from its outer catch — so a streaming command that hits its --timeout reports a JSON error inside its EOR-delimited record instead of killing the long-lived batch process. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
90 lines
3.3 KiB
C#
90 lines
3.3 KiB
C#
using Grpc.Core;
|
|
using ZB.MOM.WW.MxGateway.Contracts.Proto;
|
|
|
|
namespace ZB.MOM.WW.MxGateway.Client;
|
|
|
|
internal interface IMxGatewayClientTransport
|
|
{
|
|
/// <summary>
|
|
/// Gets the client configuration options.
|
|
/// </summary>
|
|
MxGatewayClientOptions Options { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the underlying gRPC client, if available.
|
|
/// </summary>
|
|
MxAccessGateway.MxAccessGatewayClient? RawClient { get; }
|
|
|
|
/// <summary>
|
|
/// Opens a new gateway session.
|
|
/// </summary>
|
|
/// <param name="request">Session open request.</param>
|
|
/// <param name="callOptions">gRPC call options.</param>
|
|
/// <returns>The session open reply.</returns>
|
|
Task<OpenSessionReply> OpenSessionAsync(
|
|
OpenSessionRequest request,
|
|
CallOptions callOptions);
|
|
|
|
/// <summary>
|
|
/// Closes an open gateway session.
|
|
/// </summary>
|
|
/// <param name="request">Session close request.</param>
|
|
/// <param name="callOptions">gRPC call options.</param>
|
|
/// <returns>The session close reply.</returns>
|
|
Task<CloseSessionReply> CloseSessionAsync(
|
|
CloseSessionRequest request,
|
|
CallOptions callOptions);
|
|
|
|
/// <summary>
|
|
/// Invokes an MXAccess command on the session.
|
|
/// </summary>
|
|
/// <param name="request">The command request.</param>
|
|
/// <param name="callOptions">gRPC call options.</param>
|
|
/// <returns>The command reply.</returns>
|
|
Task<MxCommandReply> InvokeAsync(
|
|
MxCommandRequest request,
|
|
CallOptions callOptions);
|
|
|
|
/// <summary>
|
|
/// Streams events from the session.
|
|
/// </summary>
|
|
/// <param name="request">The stream events request.</param>
|
|
/// <param name="callOptions">gRPC call options.</param>
|
|
/// <returns>An async enumerable of events.</returns>
|
|
IAsyncEnumerable<MxEvent> StreamEventsAsync(
|
|
StreamEventsRequest request,
|
|
CallOptions callOptions);
|
|
|
|
/// <summary>
|
|
/// Acknowledges an active MXAccess alarm condition.
|
|
/// </summary>
|
|
/// <param name="request">The acknowledge request.</param>
|
|
/// <param name="callOptions">gRPC call options.</param>
|
|
/// <returns>The acknowledge reply with native MxStatus.</returns>
|
|
Task<AcknowledgeAlarmReply> AcknowledgeAlarmAsync(
|
|
AcknowledgeAlarmRequest request,
|
|
CallOptions callOptions);
|
|
|
|
/// <summary>
|
|
/// Streams a snapshot of all alarms currently in Active or ActiveAcked state — the
|
|
/// ConditionRefresh equivalent for the gateway.
|
|
/// </summary>
|
|
/// <param name="request">The query request, optionally scoped by alarm-reference prefix.</param>
|
|
/// <param name="callOptions">gRPC call options.</param>
|
|
/// <returns>An async enumerable of active-alarm snapshots.</returns>
|
|
IAsyncEnumerable<ActiveAlarmSnapshot> QueryActiveAlarmsAsync(
|
|
QueryActiveAlarmsRequest request,
|
|
CallOptions callOptions);
|
|
|
|
/// <summary>
|
|
/// Attaches to the gateway's central alarm feed — the current active-alarm
|
|
/// snapshot followed by live transitions.
|
|
/// </summary>
|
|
/// <param name="request">The stream request, optionally scoped by alarm-reference prefix.</param>
|
|
/// <param name="callOptions">gRPC call options.</param>
|
|
/// <returns>An async enumerable of alarm feed messages.</returns>
|
|
IAsyncEnumerable<AlarmFeedMessage> StreamAlarmsAsync(
|
|
StreamAlarmsRequest request,
|
|
CallOptions callOptions);
|
|
}
|