Class: LogStash::Inputs::Base

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

Overview

This is the base class for Logstash inputs.

Constant Summary

Constants included from Config::Mixin

Config::Mixin::PLUGIN_VERSION_0_9_0, Config::Mixin::PLUGIN_VERSION_1_0_0

Constants included from Util::SubstitutionVariables

Util::SubstitutionVariables::SUBSTITUTION_PLACEHOLDER_REGEX

Instance Attribute Summary collapse

Attributes included from Config::Mixin

#config, #original_params

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Config::Mixin

#config_init, included

Methods included from Util::SubstitutionVariables

#deep_replace, #replace_placeholders

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



56
57
58
59
60
61
62
# File 'lib/logstash/inputs/base.rb', line 56

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

Class Method Details

.plugin_typeObject



51
52
53
# File 'lib/logstash/inputs/base.rb', line 51

def self.plugin_type
  "input"
end

Instance Method Details

#cloneObject



96
97
98
99
100
# File 'lib/logstash/inputs/base.rb', line 96

def clone
  cloned = super
  cloned.codec = @codec.clone if @codec
  cloned
end

#do_stopObject



84
85
86
87
88
# File 'lib/logstash/inputs/base.rb', line 84

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

#execution_context=(context) ⇒ Object



102
103
104
105
106
107
108
109
110
# File 'lib/logstash/inputs/base.rb', line 102

def execution_context=(context)
  super
  # There is no easy way to propage an instance variable into the codec, because the codec
  # are created at the class level
  # TODO(talevy): Codecs should have their own execution_context, for now they will inherit their
  #               parent plugin's
  @codec.execution_context = context
  context
end

#registerObject



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

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



79
80
81
# File 'lib/logstash/inputs/base.rb', line 79

def stop
  # override if necessary
end

#stop?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/logstash/inputs/base.rb', line 92

def stop?
  @stop_called.value
end

#tag(newtag) ⇒ Object



70
71
72
# File 'lib/logstash/inputs/base.rb', line 70

def tag(newtag)
  @tags << newtag
end