refactor example-scheduler controller-context generation into factory func
@@ -28,7 +28,13 @@ func Run(cfg Config) error {
}
var (
frameworkInfo = buildFrameworkInfo(cfg)
- controlContext = &controllerContext{
+ controlContext = buildControllerContext(state, frameworkInfo)
+ )
+ return controller.Run(controlContext, frameworkInfo, state.cli)
+}
+
+func buildControllerContext(state *internalState, frameworkInfo *mesos.FrameworkInfo) controller.Context {
+ return &controllerContext{
events: events.Decorators{
eventMetrics(state.metricsAPI, time.Now, state.config.summaryMetrics),
events.Decorator(logAllEvents).If(state.config.verbose),
@@ -52,8 +58,6 @@ func Run(cfg Config) error {
state: state,
registrationTokens: backoff.Notifier(1*time.Second, 15*time.Second, nil),
}
- )
- return controller.Run(controlContext, frameworkInfo, state.cli)
}
// buildEventHandler generates and returns a handler to process events received from the subscription.
