Class EventEmitter

java.lang.Object
ai.pipestream.module.pipelineprobe.pipelinecrawl.EventEmitter

public final class EventEmitter extends Object
Wraps the gRPC response observer with the boilerplate common to every progress event: serialization on the observer, Timestamp build, pretty step name lookup. Single place where we hold the synchronized(observer) contract.

Step ids are a small fixed vocabulary (init/dispatch/running/summary); the FE keys on step_id to render the four progress rows. Adding a new step id requires updating both this class's PRETTY_NAMES and the FE's progress-feed.

Not thread-safe to construct multiple instances against the same observer — there is exactly one EventEmitter per orchestration run.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    All step ids we emit, in order.
  • Constructor Summary

    Constructors
    Constructor
    Description
    EventEmitter(io.grpc.stub.StreamObserver<ai.pipestream.testing.harness.v1.RunPipelineCrawlResponse> observer)
    Creates the emitter bound to a single run's response observer.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close the response stream.
    void
    emit(String stepId, ai.pipestream.testing.harness.v1.E2EStepOutcome outcome, String message, long durationMs, List<ai.pipestream.testing.harness.v1.ObservationSnapshot> observations)
    Push a single progress event.
    void
    emit(String stepId, ai.pipestream.testing.harness.v1.E2EStepOutcome outcome, String message, long durationMs, List<ai.pipestream.testing.harness.v1.ObservationSnapshot> observations, com.google.protobuf.Struct details)
    Push a single progress event carrying a free-form details Struct (e.g.
    void
    emitOutput(String message, com.google.protobuf.Struct details)
    Emit an out-of-band "output" event carrying the final processed document (single-doc flow) in details.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • TOTAL_STEPS

      public static final int TOTAL_STEPS
      All step ids we emit, in order.
      See Also:
  • Constructor Details

    • EventEmitter

      public EventEmitter(io.grpc.stub.StreamObserver<ai.pipestream.testing.harness.v1.RunPipelineCrawlResponse> observer)
      Creates the emitter bound to a single run's response observer.
      Parameters:
      observer - the gRPC response stream all events are written to; must be non-null
      Throws:
      IllegalArgumentException - if observer is null
  • Method Details

    • emit

      public void emit(String stepId, ai.pipestream.testing.harness.v1.E2EStepOutcome outcome, String message, long durationMs, List<ai.pipestream.testing.harness.v1.ObservationSnapshot> observations)
      Push a single progress event. stepId must be one of the keys in PRETTY_NAMES; an unknown id throws — drift between this class and the FE is a bug, not a fallback case.
      Parameters:
      stepId - the step id to emit; must be a known key (delegates with no details)
      outcome - the step's outcome
      message - a human-readable status message for the step
      durationMs - the step's elapsed time in milliseconds
      observations - observation snapshots to attach, or null/empty for none
    • emit

      public void emit(String stepId, ai.pipestream.testing.harness.v1.E2EStepOutcome outcome, String message, long durationMs, List<ai.pipestream.testing.harness.v1.ObservationSnapshot> observations, com.google.protobuf.Struct details)
      Push a single progress event carrying a free-form details Struct (e.g. the OS-drain phase's per-tick receipt + index counts).
      Parameters:
      stepId - the step id to emit; must be a known key in PRETTY_NAMES
      outcome - the step's outcome
      message - a human-readable status message for the step
      durationMs - the step's elapsed time in milliseconds
      observations - observation snapshots to attach, or null/empty for none
      details - a free-form details Struct to attach, or null for none
      Throws:
      IllegalArgumentException - if stepId is not a known step id
    • emitOutput

      public void emitOutput(String message, com.google.protobuf.Struct details)
      Emit an out-of-band "output" event carrying the final processed document (single-doc flow) in details. NOT a numbered progress step — step_number stays 0 so the 4-step progress bar is untouched; the FE keys off step_id == "output" to render the output panel.
      Parameters:
      message - a short caption (e.g. the doc id)
      details - the decoded PipeDoc as a Struct (raw vectors stripped)
    • close

      public void close()
      Close the response stream. Called once at the end of the orchestration run regardless of outcome. Safe to call after the stream is already torn down (logs at debug, doesn't propagate).