Skip to content

Commit

Permalink
define Loader as interface
Browse files Browse the repository at this point in the history
  • Loading branch information
urso committed Feb 27, 2020
1 parent fdb87eb commit fc4bad0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions filebeat/input/v2/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import (
"github.com/elastic/beats/libbeat/logp"
)

type Loader struct {
type Loader interface {
Configure(log *logp.Logger, config *common.Config) (Input, error)
}

type InputLoader struct {
plugins map[string]Plugin

DefaultType string
Expand All @@ -34,9 +38,9 @@ type inputTypeConfig struct {
Type string `config:"type"`
}

func NewLoader(
func NewInputLoader(
plugins ...Plugin,
) (*Loader, error) {
) (*InputLoader, error) {
m := make(map[string]Plugin, len(plugins))
for _, p := range plugins {
name := p.Name
Expand All @@ -47,10 +51,10 @@ func NewLoader(
m[name] = p
}

return &Loader{plugins: m}, nil
return &InputLoader{plugins: m}, nil
}

func (l *Loader) Configure(log *logp.Logger, config *common.Config) (Input, error) {
func (l *InputLoader) Configure(log *logp.Logger, config *common.Config) (Input, error) {
typeConfig, err := unpackTypeConfig(l.DefaultType, config)
if err != nil {
return nil, err
Expand Down

0 comments on commit fc4bad0

Please sign in to comment.