105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'lib/log-courier/client.rb', line 105
def initialize(options = {})
@options = {
logger: nil,
transport: 'tls',
spool_size: 1024,
idle_timeout: 5,
port: nil,
addresses: [],
}.merge!(options)
@logger = @options[:logger]
case @options[:transport]
when 'tcp', 'tls'
require 'log-courier/client_tcp'
@client = ClientTcp.new(@options)
else
fail 'output/courier: \'transport\' must be tcp or tls'
end
fail 'output/courier: \'addresses\' must contain at least one address' if @options[:addresses].empty?
fail 'output/courier: \'addresses\' only supports a single address at this time' if @options[:addresses].length > 1
@event_queue = EventQueue.new @options[:spool_size]
@pending_payloads = {}
@first_payload = nil
@last_payload = nil
@send_ready = false
@send_mutex = Mutex.new
@send_cond = ConditionVariable.new
@spooler_thread = Thread.new do
run_spooler
end
@keepalive_timeout = 1800
@network_timeout = 30
@max_pending_payloads = 100
@retry_payload = nil
@received_payloads = Queue.new
@pending_ping = false
@io_control = EventQueue.new 1
@io_thread = Thread.new do
run_io
end
end
|