Richer Plugin Configuration Syntax
- Dominant language
- Java
- Stars
- 14.9k
- Forks
- 3.5k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 88
Description
Currently working with configurations is awkward for a few reasons
- Mixins can't namespace their configuration. It would be nice to let a plugin including a mixin include all its configs under a certain root level config (perhaps multiple times under different names!)
- Doc generation is weird with the current comment syntax. This precludes programatic config generation and nesting
- Use of @ivars makes plugin authors work around naming conflicts. If I have a config var now named `queue` for the queue name I must later write `@queue_inst = SomeQueue.new(@queue)`. I'd prefer to write `@queue = SomeQueue.new(config.queue_name)`.
@ph mentioned having a full separate configuration class, I agree. I would like some sort of `Configuration` object that could be used something like in the example below. I think the syntax here could be better, but I would like all the capabilities used here.
``` ruby
class HTTPClient
include LogStash::PluginConfig
config :http_host, :default => "127.0.0.1", :doc => "The HTTP Host"
config :http_port, :default => 80, :doc => "The HTTP Port"
end
class HTTPZipper
include LogStash::PluginConfig
config :foo, :default => "bar", :doc => "Some option"
config :http_client_a, :nest => HTTPClient.config
config :http_client_b, :nest => HTTPClient.config
config :my_nested_config, :nest => {:foo => {:default => "baz"}, :bar => {:default => "bot"}}
def do_something
@foo = new Foo(config.foo)
@http_client_a = new HTTPClient(config.http_client_a)
@http_client_b = new HTTPClient(config.http_client_b)
@my_nested_thing = config.my_nested_config
# Looks like {"foo" => "baz", "bar" => "bot"
end
end
```
Contributor guide
Assessment
This issue has not been assessed yet.