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.

Direct Known Subclasses

Threadable

Constant Summary

Constants included from Config::Mixin

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Config::Mixin

#config_init, included, #replace_env_placeholders

Methods included from Util::Loggable

included, #logger, #slow_logger

Methods inherited from Plugin

#close, #config_name, #debug_info, #do_close, #eql?, #hash, #id, #inspect, lookup, #metric, #metric=, #reloadable?, reloadable?, #to_s

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



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

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.



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

def params
  @params
end

#threadableObject

Returns the value of attribute threadable.



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

def threadable
  @threadable
end

Class Method Details

.plugin_typeObject



53
54
55
# File 'lib/logstash/inputs/base.rb', line 53

def self.plugin_type
  "input"
end

Instance Method Details

#do_stopObject



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

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

#registerObject



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

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



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

def stop
  # override if necessary
end

#stop?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/logstash/inputs/base.rb', line 94

def stop?
  @stop_called.value
end

#tag(newtag) ⇒ Object



72
73
74
# File 'lib/logstash/inputs/base.rb', line 72

def tag(newtag)
  @tags << newtag
end