Class: LogStash::Inputs::Base

Inherits:
Plugin
  • Object
show all
Includes:
Config::Mixin
Defined in:
lib/logstash/inputs/base.rb

Overview

This is the base class for Logstash inputs.

Direct Known Subclasses

Threadable

Constant Summary

Constants included from Config::Mixin

Config::Mixin::ALLOW_ENV_FLAG, Config::Mixin::ENV_PLACEHOLDER_REGEX, Config::Mixin::PLUGIN_VERSION_0_9_0, Config::Mixin::PLUGIN_VERSION_1_0_0

Constants inherited from Plugin

Plugin::NL

Instance Attribute Summary collapse

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger

Instance Method Summary collapse

Methods included from Config::Mixin

#config_init, included, #replace_env_placeholders

Methods inherited from Plugin

#close, #debug_info, #do_close, #eql?, #hash, #inspect, lookup, #to_s

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



52
53
54
55
56
57
58
# File 'lib/logstash/inputs/base.rb', line 52

def initialize(params={})
  super
  @threadable = false
  @stop_called = Concurrent::AtomicBoolean.new(false)
  config_init(@params)
  @tags ||= []
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



48
49
50
# File 'lib/logstash/inputs/base.rb', line 48

def params
  @params
end

#threadableObject

Returns the value of attribute threadable.



49
50
51
# File 'lib/logstash/inputs/base.rb', line 49

def threadable
  @threadable
end

Instance Method Details

#do_stopObject



80
81
82
83
84
# File 'lib/logstash/inputs/base.rb', line 80

def do_stop
  @logger.debug("stopping", :plugin => self)
  @stop_called.make_true
  stop
end

#registerObject



61
62
63
# File 'lib/logstash/inputs/base.rb', line 61

def register
  raise "#{self.class}#register must be overidden"
end

#stopObject

override stop if you need to do more than do_stop to enforce the input plugin to return from ‘run`. e.g. a tcp plugin might need to close the tcp socket so blocking read operation aborts



75
76
77
# File 'lib/logstash/inputs/base.rb', line 75

def stop
  # override if necessary
end

#stop?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/logstash/inputs/base.rb', line 88

def stop?
  @stop_called.value
end

#tag(newtag) ⇒ Object



66
67
68
# File 'lib/logstash/inputs/base.rb', line 66

def tag(newtag)
  @tags << newtag
end