You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Input plugins are now shutdown by an external call to plugin.stop instead of catching LogStash::ShutdownSignal exception.
Unless overridden, stop will simply makes stop? return true, thus allowing run to poll this and return after seeing the change.
In some plugins extra work must be done in stop to instruct run that it's time to return. For example, in the logstash-input-udp it's necessary to call @socket.close to make the blocking read on the socket raise an exception, thus breaking out the loop.
So, different input plugins will require different stop strategies.
Refactoring an input plugin involves:
removing rescue of ShutdownSignal exception
understand the nature of the run loop: is it a while? a consumer.subscribe {|event| }? is there a blocking operation on a socket/fd?
use stop? and/or override stop to make run return
put any other cleanup/bookkeeping tasks in close (currently done in teardown)
remove any calls to shutdown, finished, finished?, running? or terminating?
Then for testing you can use the shared example provided in logstash-devutils:
A follow up to #3813. This issue focuses on plugins that are not listed in #3813
Recap of refactor task
stop
(public),stop?
(public) to LogStash::Inputs::Baseteardown
toclose
shutdown
,finished
.finished?
,running?
,terminating?
from LogStash::PluginRefactor work needed on the plugins
Input plugins
Input plugins are now shutdown by an external call to
plugin.stop
instead of catching LogStash::ShutdownSignal exception.Unless overridden,
stop
will simply makesstop?
returntrue
, thus allowingrun
to poll this and return after seeing the change.In some plugins extra work must be done in
stop
to instructrun
that it's time to return. For example, in thelogstash-input-udp
it's necessary to call@socket.close
to make the blocking read on the socket raise an exception, thus breaking out the loop.So, different input plugins will require different
stop
strategies.Refactoring an input plugin involves:
ShutdownSignal
exceptionrun
loop: is it awhile
? aconsumer.subscribe {|event| }
? is there a blocking operation on a socket/fd?stop?
and/or overridestop
to make run returnclose
(currently done inteardown
)shutdown
,finished
,finished?
,running?
orterminating?
Then for testing you can use the shared example provided in logstash-devutils:
Input plugin refactor
2. Remove
terminating?
In a lot of scenarios the call to
terminating?
might be replaced withstop?
in the case of input plugins3. Remove
finished
7. Rename
teardown
toclose
The text was updated successfully, but these errors were encountered: