summaryrefslogtreecommitdiff
path: root/conf
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2017-01-20 21:03:08 +0100
committerSilvan Jegen <s.jegen@gmail.com>2017-01-20 21:03:08 +0100
commit5c24009f2b1fd5a7e5abd4dc33ebdec0c6eaaf25 (patch)
tree7447a384efe6a5b45106fde621e53bdf38ad608a /conf
parentba15251035961020363fa5aff95ff0a361023af9 (diff)
Introduce registry
We introduce a registry that contains maps to builder functions. These builder functions return the interface implementation of the modules specified in the configuration. We also make the input module type use the registry. All other module types still have to be converted.
Diffstat (limited to 'conf')
-rw-r--r--conf/parser.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/conf/parser.go b/conf/parser.go
index 6aca3aa..bdec888 100644
--- a/conf/parser.go
+++ b/conf/parser.go
@@ -19,6 +19,8 @@ import (
"fmt"
"io"
"os"
+
+ "github.com/Shugyousha/stasher/registry"
)
// Having a Config to Manager function could be nice? Or we could just
@@ -55,6 +57,11 @@ func NewConfig(r io.Reader) *Config {
func (p *parser) startparsing() {
inputmdesc := p.module("input")
fmt.Fprintf(os.Stderr, "input moduledesc: %#v\n", inputmdesc)
+ inputfunc, ok := registry.Inputregistry[inputmdesc.name]
+ if !ok {
+ fmt.Fprintf(os.Stderr, "input module is not known: %q\n", inputmdesc.name)
+ }
+ inputfunc(nil)
filtermdesc := p.module("filter")
fmt.Fprintf(os.Stderr, "filter moduledesc: %#v\n", filtermdesc)