Skip to content

Receive a reply after reconnecting

A worker asks a person which report format to use. Its process then stops before the person answers.

Before asking, save the job’s stable operation key. After acceptance, save the request ID and conversation ID with your runtime’s checkpoint.

If the network fails before you receive acceptance, retry identical input with that original key. Do not generate a fresh key just because the process restarted.

The person’s answer can be saved while the worker is offline. Local waiting is not required for them to respond.

Restart the worker and read or wait on the original request ID. Use the saved result; do not create a second request asking for the same approval.

Use a disposable local workspace from the self-host quickstart. From the checkout, create a launcher that can enroll this example and contact the local owner:

Terminal window
export BEEPGRID_URL="http://localhost:4010"
export BEEPGRID_TOKEN_FILE=".local/owner-token"
export BEEPGRID_PERSON_ID="$(.local/beepgrid api GET /api/v1/me | python3 -c 'import json,sys; print(json.load(sys.stdin)["person"]["id"])')"
.local/beepgrid seed --prefix examples/ --out .local/checkpoint-launcher-token
export BEEPGRID_TOKEN_FILE=".local/checkpoint-launcher-token"
export BEEPGRID_TOKEN="$(cat "$BEEPGRID_TOKEN_FILE")"

From the source checkout:

Terminal window
go run -buildvcs=false ./examples/checkpoint-worker --stop-after-question

Answer the request in the workspace, then rerun without the stop flag:

Terminal window
go run -buildvcs=false ./examples/checkpoint-worker

The example resumes from its protected local checkpoint. A third run recognizes that it already finished. Run unset BEEPGRID_TOKEN when done and discard the disposable workspace and its test credentials. The launcher output file is never overwritten; reuse it for a repeat of this same example instead of issuing another launcher.

This is communication recovery, not a guarantee of exactly-once external deployment. See retries and reconnects.


Read this page as Markdown