Skip to content

Commit 839e0aa

Browse files
committed
feat(execd): extract stream buffer (sbuf) package for ring buffer queue
1 parent 4098580 commit 839e0aa

2 files changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/execd-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ jobs:
101101
102102
sleep 5
103103
python3 tests/smoke_api.py
104+
python3 tests/command_resume_test.py
104105
- name: Show logs
105106
if: always()
106107
run: |

specs/execd-api.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,56 @@ paths:
502502
"500":
503503
$ref: "#/components/responses/InternalServerError"
504504

505+
/command/{id}/resume:
506+
get:
507+
summary: Resume command SSE stream (replay and optional live tail)
508+
description: |
509+
Replays stdout/stderr events from the server-side ring buffer for events with
510+
`eid` strictly greater than `after_eid`, then—if the command is still running and
511+
no other client holds the primary SSE slot—continues streaming live events until
512+
completion or client disconnect. Event shape matches `POST /command` (`ServerStreamEvent`).
513+
514+
This endpoint is mutually exclusive with the primary `POST /command` SSE: if that
515+
connection is still active, the server responds with 409 Conflict.
516+
operationId: resumeCommandStream
517+
tags:
518+
- Command
519+
parameters:
520+
- name: id
521+
in: path
522+
required: true
523+
description: Command ID returned by RunCommand
524+
schema:
525+
type: string
526+
example: cmd-abc123
527+
- name: after_eid
528+
in: query
529+
required: false
530+
description: |
531+
Only events with `eid` greater than this value are replayed from the buffer first
532+
(then optional live tail). Omit or use `0` to replay from the oldest buffered events.
533+
schema:
534+
type: integer
535+
format: int64
536+
minimum: 0
537+
default: 0
538+
example: 42
539+
responses:
540+
"200":
541+
description: Stream of command execution events (replay then optional live continuation)
542+
content:
543+
text/event-stream:
544+
schema:
545+
$ref: "#/components/schemas/ServerStreamEvent"
546+
"400":
547+
$ref: "#/components/responses/BadRequest"
548+
"404":
549+
$ref: "#/components/responses/NotFound"
550+
"409":
551+
$ref: "#/components/responses/Conflict"
552+
"500":
553+
$ref: "#/components/responses/InternalServerError"
554+
505555
/command/{id}/logs:
506556
get:
507557
summary: Get background command stdout/stderr (non-streamed)
@@ -1396,6 +1446,16 @@ components:
13961446
code: FILE_NOT_FOUND
13971447
message: "file not found"
13981448

1449+
Conflict:
1450+
description: Request conflicts with current server state (e.g. resource in use)
1451+
content:
1452+
application/json:
1453+
schema:
1454+
$ref: "#/components/schemas/ErrorResponse"
1455+
example:
1456+
code: INVALID_REQUEST_BODY
1457+
message: "primary SSE stream is still active; disconnect it before resuming"
1458+
13991459
InternalServerError:
14001460
description: Runtime server error during operation
14011461
content:

0 commit comments

Comments
 (0)