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.
- #pause_send ⇒ Object
- #resume_send ⇒ Object
- #send(signature, message) ⇒ Object
- #send_paused? ⇒ Boolean
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( = {}) @options = { logger: nil, port: nil, addresses: [], ssl_ca: nil, ssl_certificate: nil, ssl_key: nil, ssl_key_passphrase: nil }.merge!() @logger = @options[:logger] [:port, :ssl_ca].each do |k| fail "output/courier: '#{k}' is required" if @options[k].nil? end fail 'output/courier: \'addresses\' must contain at least one address' if @options[: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 76 |
# File 'lib/log-courier/client_tls.rb', line 54 def connect(io_control) loop do begin break if tls_connect rescue ShutdownSignal raise end # TODO: Make this configurable sleep 5 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
78 79 80 81 82 83 84 |
# File 'lib/log-courier/client_tls.rb', line 78 def disconnect @send_thread.raise ShutdownSignal @send_thread.join @recv_thread.raise ShutdownSignal @recv_thread.join return end |
#pause_send ⇒ Object
92 93 94 95 96 97 |
# File 'lib/log-courier/client_tls.rb', line 92 def pause_send return if @send_paused @send_paused = true @send_q << nil return end |
#resume_send ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/log-courier/client_tls.rb', line 103 def resume_send if @send_paused @send_paused = false @send_q << nil end return end |
#send(signature, message) ⇒ Object
86 87 88 89 90 |
# File 'lib/log-courier/client_tls.rb', line 86 def send(signature, ) # Add to send queue @send_q << [signature, .length].pack('A4N') + return end |
#send_paused? ⇒ Boolean
99 100 101 |
# File 'lib/log-courier/client_tls.rb', line 99 def send_paused? @send_paused end |