forked from graniticio/granitic
/
builder.go
45 lines (34 loc) · 1.36 KB
/
builder.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
// Copyright 2018 Granitic. All rights reserved.
// Use of this source code is governed by an Apache 2.0 license that can be found in the LICENSE file at the root of this project.
package taskscheduler
import (
"github.com/graniticio/granitic/config"
"github.com/graniticio/granitic/instance"
"github.com/graniticio/granitic/ioc"
"github.com/graniticio/granitic/logging"
"github.com/graniticio/granitic/schedule"
)
// The name of the TaskScheduler component as stored in the IoC framework.
const facilityName = "TaskScheduler"
const TaskSchedulerComponentName = instance.FrameworkPrefix + facilityName
// Creates the components that make up the TaskScheduler facility
type TaskSchedulerFacilityBuilder struct {
}
// See FacilityBuilder.BuildAndRegister
func (fb *TaskSchedulerFacilityBuilder) BuildAndRegister(lm *logging.ComponentLoggerManager, ca *config.ConfigAccessor, cn *ioc.ComponentContainer) error {
ts := new(schedule.TaskScheduler)
ts.FrameworkLogManager = lm
ts.State = ioc.StoppedState
//Inject JSON config
ca.Populate(facilityName, ts)
cn.WrapAndAddProto(TaskSchedulerComponentName, ts)
return nil
}
// See FacilityBuilder.FacilityName
func (fb *TaskSchedulerFacilityBuilder) FacilityName() string {
return facilityName
}
// See FacilityBuilder.DependsOnFacilities
func (fb *TaskSchedulerFacilityBuilder) DependsOnFacilities() []string {
return []string{}
}