forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
factory.go
37 lines (32 loc) · 1023 Bytes
/
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
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"
"github.com/elastic/beats/libbeat/logp"
)
// Factory is a factory for registrars
type Factory struct {
outlet channel.OutleterFactory
registrar *registrar.Registrar
beatDone chan struct{}
}
// NewFactory instantiates a new Factory
func NewFactory(outlet channel.OutleterFactory, registrar *registrar.Registrar, beatDone chan struct{}) *Factory {
return &Factory{
outlet: outlet,
registrar: registrar,
beatDone: beatDone,
}
}
// Create creates a prospector based on a config
func (r *Factory) Create(c *common.Config) (cfgfile.Runner, error) {
p, err := NewProspector(c, r.outlet, r.beatDone, r.registrar.GetStates())
if err != nil {
logp.Err("Error creating prospector: %s", err)
// In case of error with loading state, prospector is still returned
return p, err
}
return p, nil
}