Skip to content

feat: stdio protocol between warmup program and rustic (#1782)#524

Open
philipmw wants to merge 1 commit into
rustic-rs:mainfrom
philipmw:warmup-protocol
Open

feat: stdio protocol between warmup program and rustic (#1782)#524
philipmw wants to merge 1 commit into
rustic-rs:mainfrom
philipmw:warmup-protocol

Conversation

@philipmw

Copy link
Copy Markdown
Contributor

JSON Lines. Each line must be a single JSON object. The object must contain at least a type field that identifies the message.

{"type":"pack-progress","warm":42}

A pack-progress message tells rustic how many of the packs in the current command invocation are expected to be warm now.

Field Type Meaning
type string Must be exactly "pack-progress".
warm integer Number of packs from this invocation expected to be warm.

rustic advances its shared progress bar using these updates.

warm is monotonically non-decreasing within a single invocation. If your program reports a lower value than a previous report, the lower value is ignored.

If your command exits successfully but never emits a pack-progress message, rustic still counts the whole invocation as complete. If it reports some progress but the final warm is less than the number of packs in the invocation, rustic counts the remaining packs as done when the command exits.

So the protocol is strictly an enhancement: emitting it gives users accurate progress; omitting it preserves the pre-protocol behavior of jumping from 0% to 100%.

rustic now captures and parses warmup program's stdout. This is a change from older versions, where the warm-up command's stdout was inherited and printed directly to the terminal.

Any stdout line that is not valid JSON is logged by rustic at info level, prefixed with [warmup], so that it is still available for debugging. Empty lines are ignored.

I plan to update rustic's documentation with this, once this change is accepted.

[JSON Lines](https://jsonlines.org). Each line must be a single JSON object.
The object must contain at least a `type` field that identifies the message.

```json
{"type":"pack-progress","warm":42}
```

A `pack-progress` message tells *rustic* how many of the packs in the current
command invocation are expected to be warm now.

| Field | Type    | Meaning |
|-------|---------|---------|
| `type` | string | Must be exactly `"pack-progress"`. |
| `warm` | integer | Number of packs from this invocation expected to be warm. |

*rustic* advances its shared progress bar using these updates.

`warm` is **monotonically non-decreasing** within a single invocation. If your
program reports a lower value than a previous report, the lower value is ignored.

If your command exits successfully but never emits a `pack-progress` message,
*rustic* still counts the whole invocation as complete. If it reports some
progress but the final `warm` is less than the number of packs in the invocation,
*rustic* counts the remaining packs as done when the command exits.

So the protocol is strictly an enhancement: emitting it gives users accurate
progress; omitting it preserves the pre-protocol behavior of jumping from 0% to
100%.

*rustic* now captures and parses warmup program's stdout. This is a change from
older versions, where the warm-up command's stdout was inherited and printed
directly to the terminal.

Any stdout line that is not valid JSON is logged by *rustic* at info level,
prefixed with `[warmup]`, so that it is still available for debugging. Empty
lines are ignored.

I plan to update rustic's documentation with this, once this change is accepted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant