On 6/15/15 1:49 PM, Jake Bailey wrote:
I'm porting an output plugin to the new interface, however I'm not
seeing where the line should be drawn between the two. Is one called
more often than the other (like on restart)?
No, they'll both be called each time. Ideally there would only be a single 
method, but for historical reasons we've ended up with two.
The TCP and ElasicSearch output plugins I'm using as a guide seem to
have initialization of things in seemingly inconsistent places, like
channels created in the Init(), but buffers for batches in Prepare(),
and TCP output only doing things in the Prepare() function that requires
the runner and helper.
This dichotomy existed even with the older API, it was just less obvious. 
Before, some initialization would happen in the Init() method, while other 
initialization would happen in the early part of the Run() method, before any 
messages were pulled off of the input channel. Anything that requires access to 
either the PluginHelper or the PluginRunner needs to happen in Prepare(), of 
course, but beyond that the two are roughly equivalent.

I'd recommend the Init() method mainly be used to validate and apply the 
configuration, while the Prepare() method is where I'd spin up any external 
goroutines and other bigger coordination tasks.
My main issue is that in my plugin, it has to grab a key from a server
before it can do anything, and should fail the plugin if it can't do
this, but both functions seem like a good place to do that get.
Indeed. I apologize for the ambiguity. Ultimately, it makes sense for us to 
combine these two methods down to one. Doing so, however, would require major 
changes to the config loading code, and it seemed like A Bad Idea™ to do that 
when there are already major changes happening to the plugin running loops.

-r

_______________________________________________
Heka mailing list
[email protected]
https://mail.mozilla.org/listinfo/heka

Reply via email to