Add hey watch - #202
Conversation
|
This is a thoughtful feature, and I like the core design: Action Cable provides the notification while the incremental feed remains the source of truth. I found a few reliability gaps worth considering before merging: 1. Ensure every posting change sends a notificationHaystack sends
I reproduced this on the dev server: a suppressed mark-all-seen operation changed the posting, but Consider separating changes-channel notifications from suppressible UI broadcasts and explicitly notifying after bulk updates. Otherwise these changes can remain invisible until another notification occurs. 2. Retry failed changes-feed readsAt Consider scheduling another catch-up attempt with backoff while preserving the current cursor. 3. Report permanent connection failuresAt Consider distinguishing expected cancellation from an unexpected subscription closure and returning an appropriate error. 4. Bound asynchronous command executionAt Consider adding bounded concurrency or a queue so slow commands cannot exhaust system resources. The overall direction is strong; addressing these cases would make the command safer and more reliable to leave running unattended. |
The command was only discoverable through `hey commands`, which made it the one top-level email command missing from `hey --help`. Being curated means the copy has to speak HEY's language, so the description talks about email threads rather than postings, and `watch` joins the terminology guard that enforces it.
Retry a failed read of the changes feed on a doubling backoff instead of consuming the notification that prompted it, report a subscription that closes without the watch being interrupted rather than exiting 0, and cap how many --run-async commands run at once.
0b0e2cc to
99e4b21
Compare
Adds a new
hey watchcommand that triggers whenever an email comes in or changes.By default
hey watchwill print events and their simplified, human-readable, content to STDOUT:When piped the output returns JSON, which is easier to work with in a structured format:
To make scripting easier there's also the
--run-asyncand--run-syncoptions which take a shell command.Whenever something comes in the command will be run and the payload will get passed in via ENV.
The sync version runs commands one after another, waiting for one to finish before starting the next.
Async just executes commands as they come in.