feat(worker): adopt negotiated frame max, bound drain, priority write scheduler (IPC-02/04 + WRK-04/07 worker half)
Worker half of the Wave 3 size/backpressure + write-ordering pass: - IPC-02: the worker adopts GatewayHello.max_frame_bytes during the handshake (WorkerFrameProtocolOptions.AdoptNegotiatedMaxMessageBytes) instead of a hard-coded default; 0 keeps the default, a value above a 256 MiB ceiling is rejected. Reader and writer share the options instance, applied before the message loop. - IPC-04: DrainEvents caps each reply at MaxDrainEventsPerReply (10_000) and treats max_events = 0 as that cap rather than 'drain the entire queue', so one diagnostic drain cannot pack a session-killing reply frame. - WRK-04: WorkerFrameWriter stamps the envelope Sequence at the actual point of writing (under the write lock) instead of at envelope creation, so the on-wire order and the stamped sequence always agree under concurrent producers. - WRK-07: the writer is now a cooperative priority scheduler — callers enqueue at Control or Event priority and the draining lock-holder writes all control frames before any event frame, so replies/faults/heartbeats jump ahead of an event backlog. Per-frame validation/size rejections fail only that frame; a stream write failure fails all queued frames. Tests: monotonic gap-free sequence under concurrency, control-before-event priority (gated stream), negotiated-max adoption, DrainEvents zero-bound. Worker builds x86 only — verified on windev.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
namespace ZB.MOM.WW.MxGateway.Worker.Ipc;
|
||||
|
||||
/// <summary>
|
||||
/// Relative scheduling priority for an outbound worker frame. The single writer task drains all
|
||||
/// pending <see cref="Control"/> frames before any <see cref="Event"/> frame, so a command reply,
|
||||
/// fault, heartbeat, or shutdown acknowledgement is not delayed behind a backlog of queued events
|
||||
/// (WRK-07). Priority only reorders the write; the frame sequence is stamped at actual write time,
|
||||
/// so the on-wire order and the envelope <c>Sequence</c> always agree (WRK-04).
|
||||
/// </summary>
|
||||
public enum WorkerFrameWritePriority
|
||||
{
|
||||
/// <summary>Control-plane frame (hello, ready, command reply, heartbeat, fault, shutdown ack). Written ahead of events.</summary>
|
||||
Control = 0,
|
||||
|
||||
/// <summary>Event frame. Written only when no control frame is pending.</summary>
|
||||
Event = 1,
|
||||
}
|
||||
Reference in New Issue
Block a user