summaryrefslogtreecommitdiff
path: root/conf
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2017-01-24 21:07:03 +0100
committerSilvan Jegen <s.jegen@gmail.com>2017-01-24 21:07:03 +0100
commit3a586419584a1fbfd9052b5bf43dcfcd657e9cb5 (patch)
tree8ef85c7e1a7e03ec514832778dd8dd19e904cd2a /conf
parent51bd6e455dea5c22f8a5c4d1579c472c4937e8d6 (diff)
Make sure the init functions of all modules are run
We also get the filter function constructor.
Diffstat (limited to 'conf')
-rw-r--r--conf/init.go13
-rw-r--r--conf/parser.go10
2 files changed, 20 insertions, 3 deletions
diff --git a/conf/init.go b/conf/init.go
new file mode 100644
index 0000000..f7d1761
--- /dev/null
+++ b/conf/init.go
@@ -0,0 +1,13 @@
+package conf
+
+import (
+ // Initialize the different modules. By importing them in this
+ // way, their constructors are registered in the registry.
+ _ "github.com/Shugyousha/stasher/input/http"
+ _ "github.com/Shugyousha/stasher/input/stdin"
+
+ _ "github.com/Shugyousha/stasher/filter/http"
+ _ "github.com/Shugyousha/stasher/filter/str"
+
+ _ "github.com/Shugyousha/stasher/output/stdout"
+)
diff --git a/conf/parser.go b/conf/parser.go
index bdec888..3e351a7 100644
--- a/conf/parser.go
+++ b/conf/parser.go
@@ -57,15 +57,19 @@ 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]
+ inputnewfunc, ok := registry.Inputregistry[inputmdesc.name]
if !ok {
fmt.Fprintf(os.Stderr, "input module is not known: %q\n", inputmdesc.name)
}
- inputfunc(nil)
+ inputnewfunc(nil)
filtermdesc := p.module("filter")
fmt.Fprintf(os.Stderr, "filter moduledesc: %#v\n", filtermdesc)
-
+ filternewfunc, ok := registry.Filterregistry[filtermdesc.name]
+ if !ok {
+ fmt.Fprintf(os.Stderr, "filter module is not known: %q\n", filtermdesc.name)
+ }
+ filternewfunc(nil)
}
func (p *parser) advanceOneToken(place string) {