blob: bc1a531c0db5cd073acf8c6e6933840ee6bba296 (
plain)
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
|
package gonf
var customPromises []*CustomPromise
func init() {
customPromises = make([]*CustomPromise, 0)
}
type CustomPromise struct {
promise Promise
}
func MakeCustomPromise(p Promise) *CustomPromise {
return &CustomPromise{
promise: p,
}
}
func (c *CustomPromise) IfRepaired(p ...Promise) Promise {
c.promise.IfRepaired(p...)
return c
}
func (c *CustomPromise) Promise() *CustomPromise {
customPromises = append(customPromises, c)
return c
}
func (c *CustomPromise) Resolve() {
c.promise.Resolve()
}
func (c CustomPromise) Status() Status {
return c.promise.Status()
}
func resolveCustomPromises() (status Status) {
status = KEPT
for _, c := range customPromises {
if c.promise.Status() == PROMISED {
c.Resolve()
switch c.promise.Status() {
case BROKEN:
return BROKEN
case REPAIRED:
status = REPAIRED
}
}
}
return
}
|