/
factory.go
63 lines (52 loc) · 1.47 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 bifrost_entitygraph
import (
"context"
"github.com/aperturerobotics/controllerbus/bus"
"github.com/aperturerobotics/controllerbus/config"
"github.com/aperturerobotics/controllerbus/controller"
rctr "github.com/aperturerobotics/entitygraph/reporter/controller"
"github.com/blang/semver"
)
// Factory constructs a EntityGraph reporter controller.
type Factory struct {
// bus is the controller bus
bus bus.Bus
}
// NewFactory builds a entitygraph controller 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)
_ = cc
return rctr.NewController(
le,
t.bus,
GetControllerInfo(),
NewReporter,
), nil
}
// GetVersion returns the version of this controller.
func (t *Factory) GetVersion() semver.Version {
return Version
}
// _ is a type assertion
var _ controller.Factory = ((*Factory)(nil))