Processor methods look redundant in packages
This might be similar to this issue.
Looks like the processor.go in error and transaction package are no different and looks like we are having redundancy.
Either we can use go embedding or refactor in a better way.Will update with some ideas.
Agree that this could be potentially simplified through one of the two methods you mentioned. If you have suggestions, feel free to also directly open a PR. Sometimes discussing code is easier :-)
Can I find some more info on the role of the processors ? Might be that helps.
A direct way can be as below
type Processor interface {
Validate(io.Reader) error
Payload
Name() string
}
type processor struct {} // this struct can implement the default methods.
func (p *processor) Transform() []beat.Event {
return p.payload.Transform()
}
Now for transaction processor we can embed the base processor so that it can access all methods of the base.
type TxProcessor struct {
Processor
}
The role of processors is to take data, validate it, transform it and convert one input event to one or multiple output events.
Composing the Processors from a base processor is very/same as we do with MetricSets in metricbeat: https://github.com/elastic/beats/blob/master/metricbeat/module/apache/status/status.go#L44 So it's definitively a direction I like.
I would also like to get @simitt and @jalvz involved on this as they were thinking about how to better structure the code quite a bit.
Sure.Will implement once we have some consensus.
Will start on this.