Class: LogStash::Outputs::Base
- Includes:
- Config::Mixin
- Defined in:
- lib/logstash/outputs/base.rb
Constant Summary
Constants included from Config::Mixin
Config::Mixin::ALLOW_ENV_FLAG, Config::Mixin::ENV_PLACEHOLDER_REGEX, Config::Mixin::PLUGIN_VERSION_0_9_0, Config::Mixin::PLUGIN_VERSION_1_0_0
Constants inherited from Plugin
Instance Attribute Summary collapse
-
#available_workers ⇒ Object
readonly
Returns the value of attribute available_workers.
-
#worker_plugins ⇒ Object
readonly
Returns the value of attribute worker_plugins.
-
#workers ⇒ Object
readonly
Returns the value of attribute workers.
-
#workers_not_supported(message = nil) ⇒ Object
readonly
TODO: Remove this in the next major version after Logstash 2.x Post 2.x it should raise an error and tell people to use the class level declaration.
Attributes included from Config::Mixin
Attributes inherited from Plugin
Class Method Summary collapse
-
.concurrency(type = nil) ⇒ Object
Set or return concurrency type.
- .declare_threadsafe! ⇒ Object
- .declare_workers_not_supported!(message = nil) ⇒ Object
- .threadsafe? ⇒ Boolean
- .workers_not_supported? ⇒ Boolean
- .workers_not_supported_message ⇒ Object
Instance Method Summary collapse
- #codec ⇒ Object
- #concurrency ⇒ Object
-
#initialize(params = {}) ⇒ Base
constructor
A new instance of Base.
-
#multi_receive(events) ⇒ Object
To be overriden in implementations.
- #receive(event) ⇒ Object
- #register ⇒ Object
Methods included from Config::Mixin
#config_init, included, #replace_env_placeholders
Methods inherited from Plugin
#close, #debug_info, #do_close, #eql?, #hash, #inspect, lookup, #metric, #to_s
Constructor Details
#initialize(params = {}) ⇒ Base
Returns a new instance of Base.
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/logstash/outputs/base.rb', line 77 def initialize(params={}) super config_init(@params) # If we're running with a single thread we must enforce single-threaded concurrency by default # Maybe in a future version we'll assume output plugins are threadsafe @single_worker_mutex = Mutex.new @receives_encoded = self.methods.include?(:multi_receive_encoded) end |
Instance Attribute Details
#available_workers ⇒ Object (readonly)
Returns the value of attribute available_workers.
28 29 30 |
# File 'lib/logstash/outputs/base.rb', line 28 def available_workers @available_workers end |
#worker_plugins ⇒ Object (readonly)
Returns the value of attribute worker_plugins.
28 29 30 |
# File 'lib/logstash/outputs/base.rb', line 28 def worker_plugins @worker_plugins end |
#workers ⇒ Object (readonly)
Returns the value of attribute workers.
28 29 30 |
# File 'lib/logstash/outputs/base.rb', line 28 def workers @workers end |
#workers_not_supported(message = nil) ⇒ Object (readonly)
TODO: Remove this in the next major version after Logstash 2.x Post 2.x it should raise an error and tell people to use the class level declaration
72 73 74 |
# File 'lib/logstash/outputs/base.rb', line 72 def workers_not_supported @workers_not_supported end |
Class Method Details
.concurrency(type = nil) ⇒ Object
Set or return concurrency type
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/logstash/outputs/base.rb', line 31 def self.concurrency(type=nil) if type @concurrency = type if type == :shared declare_threadsafe! elsif type == :single declare_workers_not_supported!("This plugin only supports one worker!") end else @concurrency || :legacy # default is :legacyo end end |
.declare_threadsafe! ⇒ Object
46 47 48 49 |
# File 'lib/logstash/outputs/base.rb', line 46 def self.declare_threadsafe! declare_workers_not_supported! @threadsafe = true end |
.declare_workers_not_supported!(message = nil) ⇒ Object
55 56 57 58 |
# File 'lib/logstash/outputs/base.rb', line 55 def self.declare_workers_not_supported!(=nil) = @workers_not_supported = true end |
.threadsafe? ⇒ Boolean
51 52 53 |
# File 'lib/logstash/outputs/base.rb', line 51 def self.threadsafe? @threadsafe == true end |
.workers_not_supported? ⇒ Boolean
64 65 66 |
# File 'lib/logstash/outputs/base.rb', line 64 def self.workers_not_supported? !!@workers_not_supported end |
.workers_not_supported_message ⇒ Object
60 61 62 |
# File 'lib/logstash/outputs/base.rb', line 60 def self. end |
Instance Method Details
#codec ⇒ Object
113 114 115 |
# File 'lib/logstash/outputs/base.rb', line 113 def codec params["codec"] end |
#concurrency ⇒ Object
99 100 101 |
# File 'lib/logstash/outputs/base.rb', line 99 def concurrency self.class.concurrency end |
#multi_receive(events) ⇒ Object
To be overriden in implementations
105 106 107 108 109 110 111 |
# File 'lib/logstash/outputs/base.rb', line 105 def multi_receive(events) if @receives_encoded self.multi_receive_encoded(codec.multi_encode(events)) else events.each {|event| receive(event) } end end |
#receive(event) ⇒ Object
94 95 96 |
# File 'lib/logstash/outputs/base.rb', line 94 def receive(event) raise "#{self.class}#receive must be overidden" end |
#register ⇒ Object
89 90 91 |
# File 'lib/logstash/outputs/base.rb', line 89 def register raise "#{self.class}#register must be overidden" end |