elastic / elastic/logstash

How to pass codecs to plugins

Open
#4,540 0 comments 0 reactions 0 assignees View on GitHub
design discuss enhancement
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.