From 3a586419584a1fbfd9052b5bf43dcfcd657e9cb5 Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Tue, 24 Jan 2017 21:07:03 +0100 Subject: Make sure the init functions of all modules are run We also get the filter function constructor. --- conf/init.go | 13 +++++++++++++ conf/parser.go | 10 +++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 conf/init.go (limited to 'conf') 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) { -- cgit v1.2.3