summaryrefslogtreecommitdiff
path: root/conf
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2017-02-16 03:28:01 +0100
committerSilvan Jegen <s.jegen@gmail.com>2017-02-16 03:28:01 +0100
commit6f82a101fbfe6a040bed68c107e1f66012b0dbab (patch)
tree757f6d4d7c6b9e74bdcd20e3d6e75f3b5a237367 /conf
parent5147048d4a67c59f799203e1cc5f79b183208cab (diff)
Return a Manager, not a Config
We are not using the manager yet though.
Diffstat (limited to 'conf')
-rw-r--r--conf/parser.go25
1 files changed, 18 insertions, 7 deletions
diff --git a/conf/parser.go b/conf/parser.go
index 29f8968..b1b4447 100644
--- a/conf/parser.go
+++ b/conf/parser.go
@@ -21,7 +21,10 @@ import (
"io"
"os"
+ "github.com/Shugyousha/stasher/filter"
+ "github.com/Shugyousha/stasher/input"
"github.com/Shugyousha/stasher/manager"
+ "github.com/Shugyousha/stasher/output"
"github.com/Shugyousha/stasher/registry"
)
@@ -48,12 +51,18 @@ func newParser(s *scanner) *parser {
func NewManagerFromConfig(r io.Reader) *manager.Manager {
p := newParser(newScanner(r))
- p.startparsing()
- return &manager.Manager{}
+ return p.parse()
}
-func (p *parser) startparsing() {
+func (p *parser) parse() *manager.Manager {
+ var (
+ in input.Input
+ filt filter.Filter
+ out output.Output
+ )
+
+ // TODO: use a loop to parse all the main modules?
inputmdescs := p.mainmodule("input")
fmt.Fprintf(os.Stderr, "input moduledescs: %#v\n", inputmdescs)
for _, idesc := range inputmdescs {
@@ -61,7 +70,7 @@ func (p *parser) startparsing() {
if !ok {
fmt.Fprintf(os.Stderr, "input module is not known: %q\n", idesc.name)
}
- inputnewfunc(nil)
+ in = inputnewfunc(idesc.keyvalues)
}
filtermdescs := p.mainmodule("filter")
@@ -71,18 +80,20 @@ func (p *parser) startparsing() {
if !ok {
fmt.Fprintf(os.Stderr, "filter module is not known: %q\n", fdesc.name)
}
- filternewfunc(nil)
+ filt = filternewfunc(nil)
}
outputmdescs := p.mainmodule("output")
fmt.Fprintf(os.Stderr, "output moduledescs: %#v\n", outputmdescs)
for _, odesc := range outputmdescs {
- filternewfunc, ok := registry.Outputregistry[odesc.name]
+ outputnewfunc, ok := registry.Outputregistry[odesc.name]
if !ok {
fmt.Fprintf(os.Stderr, "output module is not known: %q\n", odesc.name)
}
- filternewfunc(nil)
+ out = outputnewfunc(nil)
}
+
+ return &manager.Manager{Input: in, Filter: filt, Output: out}
}
func (p *parser) advanceOneToken(place string) {