Class: LogStash::Plugin
- Inherits:
-
Object
- Object
- LogStash::Plugin
- Defined in:
- lib/logstash/plugin.rb
Direct Known Subclasses
Constant Summary collapse
- NL =
"\n"
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#params ⇒ Object
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #finished ⇒ Object
- #finished? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(params = nil) ⇒ Plugin
constructor
A new instance of Plugin.
- #inspect ⇒ Object
- #reload ⇒ Object
- #running? ⇒ Boolean
- #shutdown(queue) ⇒ Object
- #teardown ⇒ Object
- #terminating? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
9 10 11 |
# File 'lib/logstash/plugin.rb', line 9 def logger @logger end |
#params ⇒ Object
Returns the value of attribute params.
8 9 10 |
# File 'lib/logstash/plugin.rb', line 8 def params @params end |
Class Method Details
.lookup(type, name) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/logstash/plugin.rb', line 126 def self.lookup(type, name) path = "logstash/#{type}s/#{name}" # first check if plugin already exists in namespace and continue to next step if not begin return namespace_lookup(type, name) rescue NameError logger.debug("Plugin not defined in namespace, checking for plugin file", :type => type, :name => name, :path => path) end # try to load the plugin file. ex.: lookup("filter", "grok") will require logstash/filters/grok require(path) # check again if plugin is now defined in namespace after the require namespace_lookup(type, name) rescue LoadError, NameError => e raise(LogStash::PluginLoadingError, I18n.t("logstash.pipeline.plugin-loading-error", :type => type, :name => name, :path => path, :error => e.to_s)) end |
Instance Method Details
#eql?(other) ⇒ Boolean
20 21 22 |
# File 'lib/logstash/plugin.rb', line 20 def eql?(other) self.class.name == other.class.name && @params == other.params end |
#finished ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/logstash/plugin.rb', line 52 def finished # TODO(sissel): I'm not sure what I had planned for this shutdown_queue # thing if @shutdown_queue @logger.info("Sending shutdown event to agent queue", :plugin => self) @shutdown_queue << self end if @plugin_state != :finished @logger.info("Plugin is finished", :plugin => self) @plugin_state = :finished end end |
#finished? ⇒ Boolean
81 82 83 |
# File 'lib/logstash/plugin.rb', line 81 def finished? return @plugin_state == :finished end |
#hash ⇒ Object
14 15 16 17 |
# File 'lib/logstash/plugin.rb', line 14 def hash params.hash ^ self.class.name.hash end |
#inspect ⇒ Object
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/logstash/plugin.rb', line 113 def inspect if !@params.nil? description = @params .reject { |k, v| v.nil? || (v.respond_to?(:empty?) && v.empty?) } .collect { |k, v| "#{k}=>#{v.inspect}" } return "<#{self.class.name} #{description.join(", ")}>" else return "<#{self.class.name} --->" end end |
#reload ⇒ Object
76 77 78 |
# File 'lib/logstash/plugin.rb', line 76 def reload # Do nothing by default end |
#running? ⇒ Boolean
86 87 88 |
# File 'lib/logstash/plugin.rb', line 86 def running? return @plugin_state != :finished end |
#shutdown(queue) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/logstash/plugin.rb', line 34 def shutdown(queue) # By default, shutdown is assumed a no-op for all plugins. # If you need to take special efforts to shutdown (like waiting for # an operation to complete, etc) teardown @logger.info("Received shutdown signal", :plugin => self) @shutdown_queue = queue if @plugin_state == :finished finished else @plugin_state = :terminating end end |
#teardown ⇒ Object
69 70 71 72 |
# File 'lib/logstash/plugin.rb', line 69 def teardown # nothing by default finished end |
#terminating? ⇒ Boolean
91 92 93 |
# File 'lib/logstash/plugin.rb', line 91 def terminating? return @plugin_state == :terminating end |
#to_s ⇒ Object
96 97 98 |
# File 'lib/logstash/plugin.rb', line 96 def to_s return "#{self.class.name}: #{@params}" end |