-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
55 lines (46 loc) · 1.9 KB
/
Copy patherrors.go
File metadata and controls
55 lines (46 loc) · 1.9 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package durable
import (
"errors"
"fmt"
"github.com/dangra/durable/kernel"
)
// ErrEngineStopping is the context cancellation cause (context.Cause)
// attempt contexts carry when the Engine is shutting down. Shutdown is
// not cancellation: return ctx.Err() and the Run resumes under the next
// Engine.
var ErrEngineStopping = errors.New("durable: engine stopping")
// PreemptedError is the context cancellation cause (context.Cause) an
// attempt context carries when the engine cancels it for a Run
// cancellation request; Cause is the request's cause. It is
// informational, for middleware that labels spans: a handler needs only
// ctx.Done(), and whatever it returns except success resolves the
// operation as canceled.
type PreemptedError struct {
Cause string
}
func (e *PreemptedError) Error() string {
if e.Cause == "" {
return "durable: attempt preempted by cancellation"
}
return "durable: attempt preempted by cancellation: " + e.Cause
}
// ErrRunNotFound is returned when no Run exists for a RunID — by a
// Pipeline's Run lookup, and by Cancel. A handler looking up a child it
// scheduled checks it.
var ErrRunNotFound = kernel.ErrRunNotFound
// ErrRunTerminal is returned by Cancel when the Run already has a committed
// terminal outcome.
var ErrRunTerminal = kernel.ErrRunTerminal
// ScheduleConflictError is returned by Schedule when a nonterminal Run
// already occupies the resource slot: a Run of the same pipeline with
// different Input, or a Run of another pipeline holding a shared mutex.
// RunID and PipelineID identify the blocking Run so the caller can
// route to its handle — or, from inside a handler, park on it with
// AwaitRun.
type ScheduleConflictError struct {
RunID RunID
PipelineID PipelineID
}
func (e *ScheduleConflictError) Error() string {
return fmt.Sprintf("durable: schedule conflict: active run %s of pipeline %q occupies the slot", e.RunID, e.PipelineID)
}