-
Notifications
You must be signed in to change notification settings - Fork 8
/
factory.go
63 lines (50 loc) · 1.49 KB
/
factory.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package stream_echo
import (
"context"
"github.com/aperturerobotics/controllerbus/bus"
"github.com/aperturerobotics/controllerbus/config"
"github.com/aperturerobotics/controllerbus/controller"
"github.com/blang/semver"
)
// ControllerID identifies the echo controller.
const ControllerID = "bifrost/stream/echo"
// Version is the controller version.
var Version = semver.MustParse("0.0.1")
// Factory constructs a controller
type Factory struct {
// bus is the controller bus
bus bus.Bus
}
// NewFactory builds a factory.
func NewFactory(bus bus.Bus) *Factory {
return &Factory{bus: bus}
}
// GetConfigID returns the configuration ID for the controller.
func (t *Factory) GetConfigID() string {
return ConfigID
}
// GetControllerID returns the unique ID for the controller.
func (t *Factory) GetControllerID() string {
return ControllerID
}
// ConstructConfig constructs an instance of the controller configuration.
func (t *Factory) ConstructConfig() config.Config {
return &Config{}
}
// Construct constructs the associated controller given configuration.
func (t *Factory) Construct(
ctx context.Context,
conf config.Config,
opts controller.ConstructOpts,
) (controller.Controller, error) {
le := opts.GetLogger()
cc := conf.(*Config)
// Construct the controller.
return NewController(le, t.bus, cc)
}
// GetVersion returns the version of this controller.
func (t *Factory) GetVersion() semver.Version {
return Version
}
// _ is a type assertion
var _ controller.Factory = ((*Factory)(nil))