-
Notifications
You must be signed in to change notification settings - Fork 5
/
directive.go
43 lines (37 loc) · 1.55 KB
/
directive.go
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
package loader
import (
"time"
"github.com/aperturerobotics/controllerbus/config"
"github.com/aperturerobotics/controllerbus/controller"
"github.com/aperturerobotics/controllerbus/directive"
"github.com/cenkalti/backoff"
)
// ExecController is a directive indicating a controller instance should be
// constructed and executed given a factory and a configuration.
// If/when the controller exits, the directive is canceled with the error.
type ExecController interface {
// Directive indicates this is a directive.
directive.Directive
// GetExecControllerFactory returns the factory desired to load.
GetExecControllerFactory() controller.Factory
// GetExecControllerConfig returns the config to load the controller with.
GetExecControllerConfig() config.Config
// GetExecControllerRetryBackoff returns the backoff to use for retries.
// If empty / nil, uses the default.
GetExecControllerRetryBackoff() func() backoff.BackOff
}
// ExecControllerValue is the value emitted to satisfy the ExecController
// directive.
type ExecControllerValue interface {
// GetUpdatedTimestamp returns the last time this info changed.
GetUpdatedTimestamp() time.Time
// GetNextRetryTimestamp returns the next time this controller will be attempted.
GetNextRetryTimestamp() time.Time
// GetController returns the current controller object.
GetController() controller.Controller
// GetError returns the error running the controller.
// Controller may still be set in this case.
GetError() error
}
// _ is a type assertion
var _ directive.Value = ((ExecControllerValue)(nil))