forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runnerfactory.go
35 lines (30 loc) · 989 Bytes
/
runnerfactory.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
package prospector
import (
"github.com/elastic/beats/filebeat/channel"
"github.com/elastic/beats/filebeat/registrar"
"github.com/elastic/beats/libbeat/cfgfile"
"github.com/elastic/beats/libbeat/common"
)
// RunnerFactory is a factory for registrars
type RunnerFactory struct {
outlet channel.Factory
registrar *registrar.Registrar
beatDone chan struct{}
}
// NewRunnerFactory instantiates a new RunnerFactory
func NewRunnerFactory(outlet channel.Factory, registrar *registrar.Registrar, beatDone chan struct{}) *RunnerFactory {
return &RunnerFactory{
outlet: outlet,
registrar: registrar,
beatDone: beatDone,
}
}
// Create creates a prospector based on a config
func (r *RunnerFactory) Create(c *common.Config, meta *common.MapStrPointer) (cfgfile.Runner, error) {
p, err := New(c, r.outlet, r.beatDone, r.registrar.GetStates(), meta)
if err != nil {
// In case of error with loading state, prospector is still returned
return p, err
}
return p, nil
}