Class JdbcDispatchSubscriber.Subscription

java.lang.Object
ai.pipestream.module.pipelineprobe.pipelinecrawl.JdbcDispatchSubscriber.Subscription
All Implemented Interfaces:
io.grpc.stub.StreamObserver<ai.pipestream.connector.jdbc.v1.StreamCrawlStatusResponse>
Enclosing class:
JdbcDispatchSubscriber

public static final class JdbcDispatchSubscriber.Subscription extends Object implements io.grpc.stub.StreamObserver<ai.pipestream.connector.jdbc.v1.StreamCrawlStatusResponse>
The active subscription. Three roles:
  1. Implements StreamObserver — receives events from the connector and hydrates the bound RunLedger.
  2. Holds the Context.CancellableContext so the orchestrator can cancel() the stream when the run ends regardless of whether the connector closed it first.
  3. Exposes any real failure to the orchestrator via terminalErrorIfReal() so the wait loop can fail fast on connector errors instead of riding the deadline.

Two failure paths are tracked separately:

  • Stream errors from onError(Throwable) — gRPC transport failures, connector aborts, our own cancel.
  • Processing errors from onNext(StreamCrawlStatusResponse) — malformed events from the connector (e.g. negative expected_row_count, missing emitted_doc_id) that the per-event handler refuses to silently accept.
When onNext throws, gRPC cancels the stream and onError fires with CANCELLED; we keep the original processing error around so it isn't silently downgraded to "subscription cancelled".
  • Method Details

    • onNext

      public void onNext(ai.pipestream.connector.jdbc.v1.StreamCrawlStatusResponse evt)
      Specified by:
      onNext in interface io.grpc.stub.StreamObserver<ai.pipestream.connector.jdbc.v1.StreamCrawlStatusResponse>
    • onError

      public void onError(Throwable t)
      Specified by:
      onError in interface io.grpc.stub.StreamObserver<ai.pipestream.connector.jdbc.v1.StreamCrawlStatusResponse>
    • onCompleted

      public void onCompleted()
      Specified by:
      onCompleted in interface io.grpc.stub.StreamObserver<ai.pipestream.connector.jdbc.v1.StreamCrawlStatusResponse>
    • cancel

      public void cancel()
      Cancel the subscription. The connector's stream will close with Status.CANCELLED; onError(Throwable) sees that and treats it as expected (no error) — unless an earlier processingError is already recorded, in which case terminalErrorIfReal() surfaces that. The parent subscriber's tracking set is updated when onError or onCompleted fires in response.
    • terminalErrorIfReal

      public Throwable terminalErrorIfReal()
      The first real failure the subscription saw, or null if everything has gone fine so far. "Real" means:
      • a connector-emitted malformed event (rejected by our onNext), OR
      • a stream error that is NOT CANCELLED from our own cancel.
      Orchestrator's wait loop polls this each tick to fail fast on connector errors instead of riding the deadline.

      processingError takes precedence — when our onNext throws, gRPC also fires onError with CANCELLED, and we want to report the original cause not the cancellation that masked it.

      Returns:
      the first real failure (processing error, or a non-CANCELLED stream error), or null if none has occurred