GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — workflow/flow_check.go at main · ubgo/workflow

Expand file tree

/

flow_check.go

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
36 lines (33 loc) · 1.31 KB
/

flow_check.go

Copy path

File metadata and controls

36 lines (33 loc) · 1.31 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package workflow
import (
"errors"
"fmt"
)
// ErrConstraint matches the error of a step that found its data breaking
// a rule the workflow relies on: an invariant that does not hold
// (Invariant), or a pre- or post-condition that failed
// (middleware.Check). Such an error is permanent: retrying the same input
// cannot make it hold, so the run fails at once and an operator sees
// which rule broke.
//
//ds:def id=errconstraint-57ytu3e7 owner=@khanakia stability=stable
var ErrConstraint = errors.New("workflow: constraint violated")
// Invariant returns nil when cond holds, and otherwise a Permanent error
// wrapping ErrConstraint with the message format and args describe
// (fmt.Sprintf rules, %w included), so a step can state what must be true
// of its data and stop the run without spending retries when it is not:
//
// if err := workflow.Invariant(order.Total >= 0, "order %s has a negative total", order.ID); err != nil {
// return nil, err
// }
//
// The error matches ErrConstraint and IsPermanent. It runs on every
// driver: a permanent error is part of the core contract.
//
//ds:def id=invariant-gu6ctdqv owner=@khanakia stability=stable
func Invariant(cond bool, format string, args ...any) error {
if cond {
return nil
}
return Permanent(fmt.Errorf("%w: %w", ErrConstraint, fmt.Errorf(format, args...)))
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.