15-http-context-cancel

command
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Example 15 — Propagate HTTP request cancellation into a workflow.

Demonstrates:

  • Running a workflow inside an http.Handler with `WithCallerContext`
  • The workflow's per-run context is cancelled when the client disconnects (or the request times out)
  • h.GetResult returns context.Canceled so the handler can decide how to respond
  • The workflow row is recorded as CANCELLED, not ERROR

This is the request-scoped pattern. Use it when the workflow should stop work the moment the caller goes away. For background work that must outlive the request, drop WithCallerContext and rely on the usual durable-recovery flow instead.

Run: go run .

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL