context.Context cancellation — cancel a running maintenance operation cleanlyPOST /maintenance/pump — start pump maintenance (~8s) POST /maintenance/valve — start valve inspection (~5s) POST /maintenance/cancel — cancel running maintenance POST /maintenance/clear — dismiss completed/cancelled result
func (s *Simulation) runMaintenance(ctx context.Context, maintType string) {
for i, step := range steps {
select {
case <-ctx.Done():
// cancelled
return
case <-time.After(1 * time.Second):
// update progress + log under lock
}
}
// completed
}
The WASM demo below simulates this — JavaScript calls Go maintenance functions directly.
Run task go-example:10 to see real HTMX partial updates.