How to pass codecs to plugins
- Dominant language
- Java
- Stars
- 14.9k
- Forks
- 3.5k
- Avg merge
- 19h 14m
- Merged PRs (30d)
- 63
Description
Hi,
during my work on #4533 I noticed that we have actually two kind of behaviours for passing codec instances during plugin creation time, basically for a config like:
```
output {
stdout {
codec => plain
}
}
```
you will receive in the `LogStash::Plugin` `initialize` method a hash like `{ "codec" => "plain" }`, but for something like:
```
output {
stdout {
codec => plain { format => "." }
}
}
```
we get the actual instance, see `{"codec"=>".", charset=>"UTF-8">}`
Looks like the actual approach is to pass an instance if the plugin gets parameters or to pass a string if not, leaving the instance creation for later steps.
A good improvement here would be to pass always the same thing, so later steps don't have to create the codec if an string is passed.
Would it be a good option, in your opinion to pass here a hash that include the class + the parameters necessary to build it and let the plugin decide when to create a new instance? create a clone? etc... Other options are also to pass always an instance, but at my understanding passing letting plugin manage their codec instance could be the best approach.
What do you think?
Contributor guide
Assessment
This issue has not been assessed yet.