feat: stdio protocol between warmup program and rustic (#1782) - #524
Conversation
|
@aawsome plz |
aawsome
left a comment
There was a problem hiding this comment.
Hi @philipmw!
Sorry for the long delay! I had too much family issues in the past months, so I am a bit struggling to catch up..
The PR is mostly fine from my side, just a few things I think can be improved..
Please tell me if you want me to change these!
[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.
62de53e to
d0d970b
Compare
Welcome back! Thanks for the comments. I revised the PR. |
|
Thanks, @aawsome ! Regarding clippy - I know it's not the first time you had to point out lint problems; sorry about that. Can you change the settings to run CI automatically for pull requests? Right now it never runs for me, saying it needs you to start it manually. |
JSON Lines. Each line must be a single JSON object. The object must contain at least a
typefield that identifies the message.{"type":"pack-progress","warm":42}A
pack-progressmessage tells rustic how many of the packs in the current command invocation are expected to be warm now.type"pack-progress".warmrustic advances its shared progress bar using these updates.
warmis 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-progressmessage, rustic still counts the whole invocation as complete. If it reports some progress but the finalwarmis 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.