Class: Fluent::Plugin::Base
Direct Known Subclasses
BareOutput, Buffer, Filter, Formatter, Input, MultiOutput, Output, Parser, ServiceDiscovery, Storage, Test::Driver::OwnerDummy
Defined Under Namespace
Classes: State
Constant Summary
Configurable::CONFIG_TYPE_REGISTRY
Instance Attribute Summary collapse
Instance Method Summary
collapse
#system_config, #system_config_override
#config, #configure_proxy_generate, #configured_section_create, included, lookup_type, register_type
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
31
32
33
34
35
36
37
38
|
# File 'lib/fluent/plugin/base.rb', line 31
def initialize
@log = nil
super
@_state = State.new(false, false, false, false, false, false, false, false, false)
@_context_router = nil
@_fluentd_worker_id = nil
@under_plugin_development = false
end
|
Instance Attribute Details
#under_plugin_development ⇒ Object
Returns the value of attribute under_plugin_development.
29
30
31
|
# File 'lib/fluent/plugin/base.rb', line 29
def under_plugin_development
@under_plugin_development
end
|
Instance Method Details
#after_shutdown ⇒ Object
120
121
122
123
|
# File 'lib/fluent/plugin/base.rb', line 120
def after_shutdown
@_state.after_shutdown = true
self
end
|
#after_shutdown? ⇒ Boolean
159
160
161
|
# File 'lib/fluent/plugin/base.rb', line 159
def after_shutdown?
@_state.after_shutdown
end
|
#after_start ⇒ Object
100
101
102
103
|
# File 'lib/fluent/plugin/base.rb', line 100
def after_start
@_state.after_start = true
self
end
|
#after_started? ⇒ Boolean
143
144
145
|
# File 'lib/fluent/plugin/base.rb', line 143
def after_started?
@_state.after_start
end
|
#before_shutdown ⇒ Object
110
111
112
113
|
# File 'lib/fluent/plugin/base.rb', line 110
def before_shutdown
@_state.before_shutdown = true
self
end
|
#before_shutdown? ⇒ Boolean
151
152
153
|
# File 'lib/fluent/plugin/base.rb', line 151
def before_shutdown?
@_state.before_shutdown
end
|
#called_in_test? ⇒ Boolean
171
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/fluent/plugin/base.rb', line 171
def called_in_test?
caller_locations.each do |location|
if location.absolute_path =~ /\/test_[^\/]+\.rb$/ return true
end
end
false
end
|
#close ⇒ Object
125
126
127
128
|
# File 'lib/fluent/plugin/base.rb', line 125
def close
@_state.close = true
self
end
|
#closed? ⇒ Boolean
163
164
165
|
# File 'lib/fluent/plugin/base.rb', line 163
def closed?
@_state.close
end
|
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/fluent/plugin/base.rb', line 54
def configure(conf)
if Fluent::Engine.supervisor_mode || (conf.respond_to?(:for_this_worker?) && conf.for_this_worker?)
workers = if conf.target_worker_ids && !conf.target_worker_ids.empty?
conf.target_worker_ids.size
else
1
end
system_config_override(workers: workers)
end
super(conf, system_config.strict_config_value)
@_state ||= State.new(false, false, false, false, false, false, false, false, false)
@_state.configure = true
self
end
|
135
136
137
|
# File 'lib/fluent/plugin/base.rb', line 135
def configured?
@_state.configure
end
|
#context_router ⇒ Object
85
86
87
|
# File 'lib/fluent/plugin/base.rb', line 85
def context_router
@_context_router
end
|
#context_router=(router) ⇒ Object
81
82
83
|
# File 'lib/fluent/plugin/base.rb', line 81
def context_router=(router)
@_context_router = router
end
|
#fluentd_worker_id ⇒ Object
48
49
50
51
52
|
# File 'lib/fluent/plugin/base.rb', line 48
def fluentd_worker_id
return @_fluentd_worker_id if @_fluentd_worker_id
@_fluentd_worker_id = (ENV['SERVERENGINE_WORKER_ID'] || 0).to_i
@_fluentd_worker_id
end
|
#has_router? ⇒ Boolean
40
41
42
|
# File 'lib/fluent/plugin/base.rb', line 40
def has_router?
false
end
|
#inspect ⇒ Object
183
184
185
186
187
188
189
|
# File 'lib/fluent/plugin/base.rb', line 183
def inspect
"#<%s:%014x>" % [self.class.name, '0x%014x' % (__id__ << 1)]
end
|
#multi_workers_ready? ⇒ Boolean
69
70
71
|
# File 'lib/fluent/plugin/base.rb', line 69
def multi_workers_ready?
true
end
|
#plugin_root_dir ⇒ Object
44
45
46
|
# File 'lib/fluent/plugin/base.rb', line 44
def plugin_root_dir
nil end
|
#reloadable_plugin? ⇒ Boolean
191
192
193
194
|
# File 'lib/fluent/plugin/base.rb', line 191
def reloadable_plugin?
self.class.class_variables.empty?
end
|
#shutdown ⇒ Object
115
116
117
118
|
# File 'lib/fluent/plugin/base.rb', line 115
def shutdown
@_state.shutdown = true
self
end
|
#shutdown? ⇒ Boolean
155
156
157
|
# File 'lib/fluent/plugin/base.rb', line 155
def shutdown?
@_state.shutdown
end
|
#start ⇒ Object
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/fluent/plugin/base.rb', line 89
def start
if @log.is_a?(Fluent::PluginLogger) && $log.respond_to?(:log_event_enabled) @log.log_event_enabled = $log.log_event_enabled
end
@_state.start = true
self
end
|
#started? ⇒ Boolean
139
140
141
|
# File 'lib/fluent/plugin/base.rb', line 139
def started?
@_state.start
end
|
#stop ⇒ Object
105
106
107
108
|
# File 'lib/fluent/plugin/base.rb', line 105
def stop
@_state.stop = true
self
end
|
#stopped? ⇒ Boolean
147
148
149
|
# File 'lib/fluent/plugin/base.rb', line 147
def stopped?
@_state.stop
end
|
#string_safe_encoding(str) {|str| ... } ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/fluent/plugin/base.rb', line 73
def string_safe_encoding(str)
unless str.valid_encoding?
log.info "invalid byte sequence is replaced in `#{str}`" if self.respond_to?(:log)
str = str.scrub('?')
end
yield str
end
|
#terminate ⇒ Object
130
131
132
133
|
# File 'lib/fluent/plugin/base.rb', line 130
def terminate
@_state.terminate = true
self
end
|
#terminated? ⇒ Boolean
167
168
169
|
# File 'lib/fluent/plugin/base.rb', line 167
def terminated?
@_state.terminate
end
|