Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: perl: allow to pass parameters to callbacks #63

Open
faxm0dem opened this issue Jul 2, 2014 · 5 comments
Open

Enhancement: perl: allow to pass parameters to callbacks #63

faxm0dem opened this issue Jul 2, 2014 · 5 comments

Comments

@faxm0dem
Copy link
Contributor

faxm0dem commented Jul 2, 2014

It would feel more natural (IMHO) to pass parameters to callbacks instead of going through value-pairs, maybe something like:

perl(
  script("elasticsearch.pm")
  init-func("init", pair("es_bulk_size", 100))
  queue-func("queue", pair("es_index", "syslog-$YEAR.$MONTH.$DAY"), pair("es_type", "syslog"))
  deinit-func("deinit")
);

or alternatively

perl(
  script(...)
  queue-func("init")
  queue-param(pair(...))
);
@algernon
Copy link
Contributor

algernon commented Jul 2, 2014

How about this:

perl(
  queue-func("queue", es_index("syslog-$YEAR.$MONTH.$DAY"), es_type("syslog"))
);

And if you want to force a type, then es_type(string("syslog")) would also work. This seems more natural than using pair(), but has the drawback of not having the whole value-pairs infrastructure underneath exposed (so you can't do key("es_*") for example).

@faxm0dem
Copy link
Contributor Author

faxm0dem commented Jul 2, 2014

that looks right to me, and I'd need the same for init-func and deinit-func

@algernon
Copy link
Contributor

algernon commented Jul 2, 2014

Yeah, I'd do it in a general way, so the same stuff can be reused for other *-func() options, in all relevant drivers. (This will take some time, though, as 3.5.5 is a much higher priority task at the moment).

@talien
Copy link
Contributor

talien commented Jul 2, 2014

For init-func, and deinit func i wouldn't do the same, because at init-time and deinit-time there is no message, on which you can apply your template. That's why we use constant globals in lua, for example. I would use the lua-style config in all scripted destinations. We will see if the semantics will differ, or we can unify them, too. (In lua, you cannot use named parameters from C, only positional ones, but in python, you can do something like that. Every language has some dict/hash/table-like structure, so I would go for that direction for scripted destinations).

@algernon
Copy link
Contributor

algernon commented Jul 2, 2014

Yeah, for init/deinit, it wouldn't be a template. But similar syntax. How it gets pushed down to the interpreter, is another matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants