Class PipelineCrawlerResource
java.lang.Object
ai.pipestream.module.pipelineprobe.pipelinecrawl.PipelineCrawlerResource
REST/SSE bridge from the FE's Pipeline tab to the gRPC
PipelineCrawlerImpl. Uses JAX-RS native server-sent events
(Sse + SseEventSink) so we stay on plain Java the whole
way through — no Mutiny anywhere in the pipeline-crawl path.
The endpoint is marked RunOnVirtualThread so the JAX-RS
runtime invokes the method on a VT. The run itself executes on a
RunRegistry-owned virtual thread — this resource only starts it
and subscribes the SSE sink as one of its watchers (journal replay +
live tail). A client disconnect detaches the watcher; the run is
unaffected and remains re-attachable via
GET runs/{runId}/events until ~30 minutes after it terminates.
Why not Multi<String> like the legacy resources: that pattern pulls Mutiny back into the new code path. JAX-RS native SSE is the platform-native way to stream events from a blocking endpoint.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordFE-facing payload. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCancel a live run.listRuns()List known runs (live + recently terminal).voidrunPipelineCrawl(PipelineCrawlerResource.PipelineCrawlPayload payload, jakarta.ws.rs.sse.Sse sse, jakarta.ws.rs.sse.SseEventSink sink) Start a pipeline-crawl run and stream its events over SSE.voidstreamRunEvents(String runId, jakarta.ws.rs.sse.Sse sse, jakarta.ws.rs.sse.SseEventSink sink) Re-attach to a run: full journal replay, then live tail.
-
Constructor Details
-
PipelineCrawlerResource
public PipelineCrawlerResource()Creates the pipeline-crawl REST/SSE resource. Collaborators (the gRPC crawler and the run registry) are injected; instances are managed by the JAX-RS / CDI runtime.
-
-
Method Details
-
runPipelineCrawl
@POST @Consumes("application/json") @Produces("text/event-stream") public void runPipelineCrawl(PipelineCrawlerResource.PipelineCrawlPayload payload, @Context jakarta.ws.rs.sse.Sse sse, @Context jakarta.ws.rs.sse.SseEventSink sink) Start a pipeline-crawl run and stream its events over SSE. Translates the FE payload to the proto request, hands it to theRunRegistryto execute on a registry-owned virtual thread, then subscribes this SSE response as a watcher (journal replay + live tail). A client disconnect detaches the watcher only; the run continues and stays re-attachable viaGET runs/{runId}/events. An invalid request shape or a failed start is reported as a single SSE error event; the sink is closed in thefinallyblock.- Parameters:
payload- the FE-facing crawl request payloadsse- the JAX-RS SSE factory used to build outbound eventssink- the SSE event sink this response writes to
-
listRuns
List known runs (live + recently terminal). Each row carries the run_id used for re-attach and cancel.- Returns:
- a JSON-shaped map with key
"runs"holding one row per known run (run_id, source, state, timestamps, journal stats and last message)
-
streamRunEvents
@GET @Path("/runs/{runId}/events") @Produces("text/event-stream") public void streamRunEvents(@PathParam("runId") String runId, @Context jakarta.ws.rs.sse.Sse sse, @Context jakarta.ws.rs.sse.SseEventSink sink) Re-attach to a run: full journal replay, then live tail. Works for live runs (watch resumes) and recently-terminal ones (replay then close). Unknown/evicted run ids answer with a single error event.- Parameters:
runId- the id of the run to re-attach tosse- the JAX-RS SSE factory used to build outbound eventssink- the SSE event sink this response writes to
-
cancelRun
@POST @Path("/runs/{runId}/cancel") @Produces("application/json") public Map<String,Object> cancelRun(@PathParam("runId") String runId) Cancel a live run. The run thread is interrupted; the orchestration maps that to a FAILED summary + ninja cleanup, so cancellation is clean by construction.- Parameters:
runId- the id of the run to cancel- Returns:
- a JSON-shaped map with the run_id, a
cancelledflag and areason(unknown run_id, interrupt sent, or already terminal)
-