Class: LogCourier::ClientTls
- Inherits:
-
Object
- Object
- LogCourier::ClientTls
- Defined in:
- lib/log-courier/client_tls.rb
Overview
TLS transport implementation
Instance Method Summary collapse
- #connect(io_control) ⇒ Object
- #disconnect ⇒ Object
-
#initialize(options = {}) ⇒ ClientTls
constructor
A new instance of ClientTls.
- #send(signature, message) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ClientTls
Returns a new instance of ClientTls.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/log-courier/client_tls.rb', line 27 def initialize( = {}) = { logger: nil, port: nil, addresses: [], ssl_ca: nil, ssl_certificate: nil, ssl_key: nil, ssl_key_passphrase: nil }.merge!() @logger = [:logger] [:port, :ssl_ca].each do |k| fail "output/courier: '#{k}' is required" if [k].nil? end fail 'output/courier: \'addresses\' must contain at least one address' if [:addresses].empty? c = 0 [:ssl_certificate, :ssl_key].each do c += 1 end fail 'output/courier: \'ssl_certificate\' and \'ssl_key\' must be specified together' if c == 1 end |
Instance Method Details
#connect(io_control) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/log-courier/client_tls.rb', line 54 def connect(io_control) begin tls_connect rescue ShutdownSignal raise rescue # TODO: Make this configurable sleep 5 retry end @send_q = SizedQueue.new 1 @send_paused = false @send_thread = Thread.new do run_send io_control end @recv_thread = Thread.new do run_recv io_control end return end |
#disconnect ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/log-courier/client_tls.rb', line 77 def disconnect @send_thread.raise ShutdownSignal @send_thread.join @recv_thread.raise ShutdownSignal @recv_thread.join return end |
#send(signature, message) ⇒ Object
85 86 87 88 89 |
# File 'lib/log-courier/client_tls.rb', line 85 def send(signature, ) # Add to send queue @send_q << [signature, .length].pack('A4N') + return end |