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

Track shutdown refactor for other plugins not packaged with logstash #3963

Open
33 of 53 tasks
jsvd opened this issue Sep 24, 2015 · 0 comments
Open
33 of 53 tasks

Track shutdown refactor for other plugins not packaged with logstash #3963

jsvd opened this issue Sep 24, 2015 · 0 comments

Comments

@jsvd
Copy link
Member

jsvd commented Sep 24, 2015

A follow up to #3813. This issue focuses on plugins that are not listed in #3813

Recap of refactor task

  1. add stop (public), stop? (public) to LogStash::Inputs::Base
  2. rename teardown to close
  3. remove shutdown, finished. finished?, running?, terminating? from LogStash::Plugin

Refactor 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 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:

describe LogStash::Inputs::Http do
  let(:port) { rand(5000) + 1025 }
  it_behaves_like "an interruptible input plugin" do
    let(:config) { { "port" => port } }
  end
end
Input plugin refactor
2. Remove terminating?

In a lot of scenarios the call to terminating? might be replaced with stop? in the case of input plugins

3. Remove finished

7. Rename teardown to close

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

No branches or pull requests

2 participants