From 5c24009f2b1fd5a7e5abd4dc33ebdec0c6eaaf25 Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Fri, 20 Jan 2017 21:03:08 +0100 Subject: 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. --- conf/parser.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'conf') 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) -- cgit v1.2.1-18-gbd029