Class: LogStashLogger::Device::TCP
- Inherits:
-
Socket
- Object
- Base
- Connectable
- Socket
- LogStashLogger::Device::TCP
- Defined in:
- lib/logstash-logger/device/tcp.rb
Constant Summary
Constants inherited from Socket
Instance Attribute Summary collapse
-
#ssl_certificate ⇒ Object
readonly
Returns the value of attribute ssl_certificate.
Attributes inherited from Socket
Attributes inherited from Connectable
Attributes inherited from Base
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize(opts) ⇒ TCP
constructor
A new instance of TCP.
- #io ⇒ Object
- #ssl_context ⇒ Object
- #use_ssl? ⇒ Boolean
Methods inherited from Socket
Methods inherited from Connectable
#close, #connected?, #flush, #on_full_buffer_receive, #reconnect, #reset, #to_io, #with_connection, #write, #write_batch, #write_one
Methods included from Buffer
#buffer_flush, #buffer_full?, #buffer_initialize, #buffer_receive, #reset_buffer
Methods inherited from Base
#close, #close!, #flush, #reset, #to_io, #unrecoverable_error?, #write, #write_batch, #write_one
Constructor Details
#initialize(opts) ⇒ TCP
Returns a new instance of TCP.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/logstash-logger/device/tcp.rb', line 8 def initialize(opts) super @ssl_certificate = opts[:ssl_certificate] @ssl_context = opts[:ssl_context] @use_ssl = !!(@ssl_certificate || opts[:ssl_context]) @use_ssl = opts[:ssl_enable] if opts.has_key? :ssl_enable if opts.has_key?(:use_ssl) @use_ssl = opts[:use_ssl] warn "[LogStashLogger] The use_ssl option is deprecated. Use ssl_enable instead." end @verify_hostname = opts.fetch(:verify_hostname, true) end |
Instance Attribute Details
#ssl_certificate ⇒ Object (readonly)
Returns the value of attribute ssl_certificate.
6 7 8 |
# File 'lib/logstash-logger/device/tcp.rb', line 6 def ssl_certificate @ssl_certificate end |
Instance Method Details
#connect ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/logstash-logger/device/tcp.rb', line 31 def connect if use_ssl? io.connect verify_hostname! end io end |
#io ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/logstash-logger/device/tcp.rb', line 39 def io @io ||= if use_ssl? ssl_io else tcp_io end end |
#ssl_context ⇒ Object
22 23 24 25 |
# File 'lib/logstash-logger/device/tcp.rb', line 22 def ssl_context return unless use_ssl? @ssl_context || certificate_context end |
#use_ssl? ⇒ Boolean
27 28 29 |
# File 'lib/logstash-logger/device/tcp.rb', line 27 def use_ssl? @use_ssl end |