Class: LogStash::Plugin
- Inherits:
-
Object
show all
- Defined in:
- lib/logstash/plugin.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(params = nil) ⇒ Plugin
Returns a new instance of Plugin.
23
24
25
26
|
# File 'lib/logstash/plugin.rb', line 23
def initialize(params=nil)
@params = params
@logger = Cabin::Channel.get(LogStash)
end
|
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
# File 'lib/logstash/plugin.rb', line 124
def self.lookup(type, name)
path = "logstash/#{type}s/#{name}"
require(path)
base = LogStash.const_get("#{type.capitalize}s")
klass = nil
klass_sym = base.constants.find { |k| base.const_get(k).config_name == name }
klass = base.const_get(klass_sym)
raise LoadError if klass.nil?
return klass
rescue LoadError => 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
18
19
20
|
# File 'lib/logstash/plugin.rb', line 18
def eql?(other)
self.class.name == other.class.name && @params == other.params
end
|
#finished ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/logstash/plugin.rb', line 50
def finished
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
79
80
81
|
# File 'lib/logstash/plugin.rb', line 79
def finished?
return @plugin_state == :finished
end
|
#hash ⇒ Object
12
13
14
15
|
# File 'lib/logstash/plugin.rb', line 12
def hash
params.hash ^
self.class.name.hash
end
|
#inspect ⇒ Object
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/logstash/plugin.rb', line 111
def inspect
if !@config.nil?
description = @config \
.select { |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
74
75
76
|
# File 'lib/logstash/plugin.rb', line 74
def reload
end
|
#running? ⇒ Boolean
84
85
86
|
# File 'lib/logstash/plugin.rb', line 84
def running?
return @plugin_state != :finished
end
|
#shutdown(queue) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/logstash/plugin.rb', line 32
def shutdown(queue)
teardown
@logger.info("Received shutdown signal", :plugin => self)
@shutdown_queue = queue
if @plugin_state == :finished
finished
else
@plugin_state = :terminating
end
end
|
#teardown ⇒ Object
67
68
69
70
|
# File 'lib/logstash/plugin.rb', line 67
def teardown
finished
end
|
#terminating? ⇒ Boolean
89
90
91
|
# File 'lib/logstash/plugin.rb', line 89
def terminating?
return @plugin_state == :terminating
end
|
#to_s ⇒ Object
94
95
96
|
# File 'lib/logstash/plugin.rb', line 94
def to_s
return "#{self.class.name}: #{@params}"
end
|