func fromConfig(ctx context.Context, cfg *config.Config) *ql.Chain { inputConfigBody, err := json.Marshal(&cfg.Input.Config) if err != nil { log.Log(ctx).Crit("Error converting input configuration to json", "error", err) return nil } inputHandler, err := ql.GetInput(cfg.Input.Driver).Build(bytes.NewReader(inputConfigBody)) if err != nil { log.Log(ctx).Crit("Error creating input handler", "error", err) return nil } chain := ql.Chain{ Input: inputHandler, InputConfig: cfg.Input.Config, Parser: ql.GetParser(cfg.Input.Parser), Output: ql.GetOutput(cfg.Output.Driver), OutputConfig: cfg.Output.Config, } if len(cfg.Filters) >= 1 { chain.Filter = ql.GetFilter(cfg.Filters[0].Driver) chain.FilterConfig = cfg.Filters[0].Config } return &chain }
func main() { chain := ql.Chain{ Input: &stdin.Process{}, //Output: &stdout.Process{}, Output: &debug.Handler{PrintFields: debug.NullableBool{NotNull: false, Value: true}}, Filter: &uuid.Handler{FieldName: "uuid"}, Parser: &plain.Parser{}, } ctx := context.Background() chain.Execute(ctx) }