net_tcp_client 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -20
- data/Rakefile +7 -7
- data/lib/net/tcp_client/address.rb +11 -6
- data/lib/net/tcp_client/exceptions.rb +3 -3
- data/lib/net/tcp_client/policy/base.rb +0 -1
- data/lib/net/tcp_client/policy/custom.rb +5 -3
- data/lib/net/tcp_client/policy/ordered.rb +1 -2
- data/lib/net/tcp_client/policy/random.rb +1 -2
- data/lib/net/tcp_client/tcp_client.rb +103 -93
- data/lib/net/tcp_client/version.rb +2 -2
- data/lib/net/tcp_client.rb +10 -10
- data/lib/net_tcp_client.rb +1 -1
- metadata +11 -37
- data/test/address_test.rb +0 -91
- data/test/policy/custom_policy_test.rb +0 -42
- data/test/policy/ordered_policy_test.rb +0 -36
- data/test/policy/random_policy_test.rb +0 -45
- data/test/simple_tcp_server.rb +0 -160
- data/test/ssl_files/ca.key +0 -27
- data/test/ssl_files/ca.pem +0 -19
- data/test/ssl_files/localhost-server-key.pem +0 -27
- data/test/ssl_files/localhost-server.pem +0 -19
- data/test/ssl_files/no-sni-key.pem +0 -27
- data/test/ssl_files/no-sni.pem +0 -20
- data/test/tcp_client_test.rb +0 -257
- data/test/test_helper.rb +0 -18
@@ -38,8 +38,8 @@ module Net
|
|
38
38
|
include SemanticLogger::Loggable if defined?(SemanticLogger::Loggable)
|
39
39
|
|
40
40
|
attr_accessor :connect_timeout, :read_timeout, :write_timeout,
|
41
|
-
|
42
|
-
|
41
|
+
:connect_retry_count, :connect_retry_interval, :retry_count,
|
42
|
+
:policy, :close_on_error, :buffered, :ssl, :proxy_server, :keepalive
|
43
43
|
attr_reader :servers, :address, :socket, :ssl_handshake_timeout
|
44
44
|
|
45
45
|
# Supports embedding user supplied data along with this connection
|
@@ -65,8 +65,8 @@ module Net
|
|
65
65
|
# Return the array of errors that will result in an automatic connection retry
|
66
66
|
# To add any additional errors to the standard list:
|
67
67
|
# Net::TCPClient.reconnect_on_errors << Errno::EPROTO
|
68
|
-
|
69
|
-
|
68
|
+
class << self
|
69
|
+
attr_reader :reconnect_on_errors
|
70
70
|
end
|
71
71
|
|
72
72
|
# Create a connection, call the supplied block and close the connection on
|
@@ -81,19 +81,17 @@ module Net
|
|
81
81
|
# connect_retry_count: 5
|
82
82
|
# ) do |client|
|
83
83
|
# client.retry_on_connection_failure do
|
84
|
-
# client.
|
84
|
+
# client.write('Update the database')
|
85
85
|
# end
|
86
86
|
# response = client.read(20)
|
87
87
|
# puts "Received: #{response}"
|
88
88
|
# end
|
89
89
|
#
|
90
|
-
def self.connect(params={})
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
connection.close if connection
|
96
|
-
end
|
90
|
+
def self.connect(params = {})
|
91
|
+
connection = new(params)
|
92
|
+
yield(connection)
|
93
|
+
ensure
|
94
|
+
connection&.close
|
97
95
|
end
|
98
96
|
|
99
97
|
# Create a new TCP Client connection
|
@@ -143,7 +141,7 @@ module Net
|
|
143
141
|
# upon use instead of possibly taking considerable time to fail.
|
144
142
|
# Default: true
|
145
143
|
#
|
146
|
-
# :connect_retry_count [
|
144
|
+
# :connect_retry_count [Integer]
|
147
145
|
# Number of times to retry connecting when a connection fails
|
148
146
|
# Default: 10
|
149
147
|
#
|
@@ -151,7 +149,7 @@ module Net
|
|
151
149
|
# Number of seconds between connection retry attempts after the first failed attempt
|
152
150
|
# Default: 0.5
|
153
151
|
#
|
154
|
-
# :retry_count [
|
152
|
+
# :retry_count [Integer]
|
155
153
|
# Number of times to retry when calling #retry_on_connection_failure
|
156
154
|
# This is independent of :connect_retry_count which still applies with
|
157
155
|
# connection failures. This retry controls upto how many times to retry the
|
@@ -220,7 +218,7 @@ module Net
|
|
220
218
|
# )
|
221
219
|
#
|
222
220
|
# client.retry_on_connection_failure do
|
223
|
-
# client.
|
221
|
+
# client.write('Update the database')
|
224
222
|
# end
|
225
223
|
#
|
226
224
|
# # Read upto 20 characters from the server
|
@@ -247,11 +245,10 @@ module Net
|
|
247
245
|
# }
|
248
246
|
# )
|
249
247
|
def initialize(server: nil, servers: nil,
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
)
|
248
|
+
policy: :ordered, buffered: true, keepalive: true,
|
249
|
+
connect_timeout: 10.0, read_timeout: 60.0, write_timeout: 60.0,
|
250
|
+
connect_retry_count: 10, retry_count: 3, connect_retry_interval: 0.5, close_on_error: true,
|
251
|
+
on_connect: nil, proxy_server: nil, ssl: nil)
|
255
252
|
@read_timeout = read_timeout.to_f
|
256
253
|
@write_timeout = write_timeout.to_f
|
257
254
|
@connect_timeout = connect_timeout.to_f
|
@@ -271,7 +268,7 @@ module Net
|
|
271
268
|
@servers = [server] if server
|
272
269
|
@servers = servers if servers
|
273
270
|
|
274
|
-
raise(ArgumentError,
|
271
|
+
raise(ArgumentError, "Missing mandatory :server or :servers") unless @servers
|
275
272
|
|
276
273
|
connect
|
277
274
|
end
|
@@ -309,27 +306,29 @@ module Net
|
|
309
306
|
begin
|
310
307
|
connect_to_server(servers, policy)
|
311
308
|
logger.info(message: "Connected to #{address}", duration: (Time.now - start_time) * 1000) if respond_to?(:logger)
|
312
|
-
rescue ConnectionFailure, ConnectionTimeout =>
|
313
|
-
cause =
|
309
|
+
rescue ConnectionFailure, ConnectionTimeout => e
|
310
|
+
cause = e.is_a?(ConnectionTimeout) ? e : e.cause
|
314
311
|
# Retry-able?
|
315
312
|
if self.class.reconnect_on_errors.include?(cause.class) && (retries < connect_retry_count.to_i)
|
316
313
|
retries += 1
|
317
|
-
|
314
|
+
if respond_to?(:logger)
|
315
|
+
logger.warn "#connect Failed to connect to any of #{servers.join(',')}. Sleeping:#{connect_retry_interval}s. Retry: #{retries}"
|
316
|
+
end
|
318
317
|
sleep(connect_retry_interval)
|
319
318
|
retry
|
320
319
|
else
|
321
|
-
message = "#connect Failed to connect to any of #{servers.join(',')} after #{retries} retries. #{
|
322
|
-
logger.benchmark_error(message, exception:
|
320
|
+
message = "#connect Failed to connect to any of #{servers.join(',')} after #{retries} retries. #{e.class}: #{e.message}"
|
321
|
+
logger.benchmark_error(message, exception: e, duration: (Time.now - start_time)) if respond_to?(:logger)
|
323
322
|
raise ConnectionFailure.new(message, address.to_s, cause)
|
324
323
|
end
|
325
324
|
end
|
326
325
|
end
|
327
326
|
|
328
|
-
#
|
327
|
+
# Write data to the server
|
329
328
|
#
|
330
|
-
# Use #with_retry to add resilience to the #
|
329
|
+
# Use #with_retry to add resilience to the #write method
|
331
330
|
#
|
332
|
-
# Raises Net::TCPClient::ConnectionFailure whenever the
|
331
|
+
# Raises Net::TCPClient::ConnectionFailure whenever the write fails
|
333
332
|
# For a description of the errors, see Socket#write
|
334
333
|
#
|
335
334
|
# Parameters
|
@@ -352,15 +351,15 @@ module Net
|
|
352
351
|
payload = {timeout: timeout}
|
353
352
|
# With trace level also log the sent data
|
354
353
|
payload[:data] = data if logger.trace?
|
355
|
-
logger.benchmark_debug(
|
354
|
+
logger.benchmark_debug("#write", payload: payload) do
|
356
355
|
payload[:bytes] = socket_write(data, timeout)
|
357
356
|
end
|
358
357
|
else
|
359
358
|
socket_write(data, timeout)
|
360
359
|
end
|
361
|
-
rescue Exception =>
|
360
|
+
rescue Exception => e
|
362
361
|
close if close_on_error
|
363
|
-
raise
|
362
|
+
raise e
|
364
363
|
end
|
365
364
|
|
366
365
|
# Returns a response from the server
|
@@ -378,7 +377,7 @@ module Net
|
|
378
377
|
# to read the response from the connection
|
379
378
|
#
|
380
379
|
# Parameters
|
381
|
-
# length [
|
380
|
+
# length [Integer]
|
382
381
|
# The number of bytes to return
|
383
382
|
# #read will not return until 'length' bytes have been received from
|
384
383
|
# the server
|
@@ -402,7 +401,7 @@ module Net
|
|
402
401
|
def read(length, buffer = nil, timeout = read_timeout)
|
403
402
|
if respond_to?(:logger)
|
404
403
|
payload = {bytes: length, timeout: timeout}
|
405
|
-
logger.benchmark_debug(
|
404
|
+
logger.benchmark_debug("#read", payload: payload) do
|
406
405
|
data = socket_read(length, buffer, timeout)
|
407
406
|
# With trace level also log the received data
|
408
407
|
payload[:data] = data if logger.trace?
|
@@ -411,12 +410,12 @@ module Net
|
|
411
410
|
else
|
412
411
|
socket_read(length, buffer, timeout)
|
413
412
|
end
|
414
|
-
rescue Exception =>
|
413
|
+
rescue Exception => e
|
415
414
|
close if close_on_error
|
416
|
-
raise
|
415
|
+
raise e
|
417
416
|
end
|
418
417
|
|
419
|
-
#
|
418
|
+
# Write and/or receive data with automatic retry on connection failure
|
420
419
|
#
|
421
420
|
# On a connection failure, it will create a new connection and retry the block.
|
422
421
|
# Returns immediately on exception Net::TCPClient::ReadTimeout
|
@@ -425,28 +424,28 @@ module Net
|
|
425
424
|
# 1. Example of a resilient _readonly_ request:
|
426
425
|
#
|
427
426
|
# When reading data from a server that does not change state on the server
|
428
|
-
# Wrap both the
|
429
|
-
# since it is safe to
|
427
|
+
# Wrap both the write and the read with #retry_on_connection_failure
|
428
|
+
# since it is safe to write the same data twice to the server
|
430
429
|
#
|
431
|
-
# # Since the
|
430
|
+
# # Since the write can be sent many times it is safe to also put the receive
|
432
431
|
# # inside the retry block
|
433
432
|
# value = client.retry_on_connection_failure do
|
434
|
-
# client.
|
433
|
+
# client.write("GETVALUE:count\n")
|
435
434
|
# client.read(20).strip.to_i
|
436
435
|
# end
|
437
436
|
#
|
438
437
|
# 2. Example of a resilient request that _modifies_ data on the server:
|
439
438
|
#
|
440
439
|
# When changing state on the server, for example when updating a value
|
441
|
-
# Wrap _only_ the
|
440
|
+
# Wrap _only_ the write with #retry_on_connection_failure
|
442
441
|
# The read must be outside the #retry_on_connection_failure since we must
|
443
|
-
# not retry the
|
442
|
+
# not retry the write if the connection fails during the #read
|
444
443
|
#
|
445
444
|
# value = 45
|
446
|
-
# # Only the
|
447
|
-
# # the
|
445
|
+
# # Only the write is within the retry block since we cannot re-write once
|
446
|
+
# # the write was successful since the server may have made the change
|
448
447
|
# client.retry_on_connection_failure do
|
449
|
-
# client.
|
448
|
+
# client.write("SETVALUE:#{count}\n")
|
450
449
|
# end
|
451
450
|
# # Server returns "SAVED" if the call was successful
|
452
451
|
# result = client.read(20).strip
|
@@ -462,20 +461,22 @@ module Net
|
|
462
461
|
begin
|
463
462
|
connect if closed?
|
464
463
|
yield(self)
|
465
|
-
rescue ConnectionFailure =>
|
466
|
-
exc_str =
|
464
|
+
rescue ConnectionFailure => e
|
465
|
+
exc_str = e.cause ? "#{e.cause.class}: #{e.cause.message}" : e.message
|
467
466
|
# Re-raise exceptions that should not be retried
|
468
|
-
if !self.class.reconnect_on_errors.include?(
|
467
|
+
if !self.class.reconnect_on_errors.include?(e.cause.class)
|
469
468
|
logger.info "#retry_on_connection_failure not configured to retry: #{exc_str}" if respond_to?(:logger)
|
470
|
-
raise
|
469
|
+
raise e
|
471
470
|
elsif retries < @retry_count
|
472
471
|
retries += 1
|
473
|
-
logger.warn "#retry_on_connection_failure retry #{retries} due to #{
|
472
|
+
logger.warn "#retry_on_connection_failure retry #{retries} due to #{e.class}: #{e.message}" if respond_to?(:logger)
|
474
473
|
connect
|
475
474
|
retry
|
476
475
|
end
|
477
|
-
|
478
|
-
|
476
|
+
if respond_to?(:logger)
|
477
|
+
logger.error "#retry_on_connection_failure Connection failure: #{e.class}: #{e.message}. Giving up after #{retries} retries"
|
478
|
+
end
|
479
|
+
raise ConnectionFailure.new("After #{retries} retries to any of #{servers.join(',')}': #{exc_str}", servers, e.cause)
|
479
480
|
end
|
480
481
|
end
|
481
482
|
|
@@ -487,14 +488,15 @@ module Net
|
|
487
488
|
@socket = nil
|
488
489
|
@address = nil
|
489
490
|
true
|
490
|
-
rescue IOError =>
|
491
|
-
logger.warn "IOError when attempting to close socket: #{
|
491
|
+
rescue IOError => e
|
492
|
+
logger.warn "IOError when attempting to close socket: #{e.class}: #{e.message}" if respond_to?(:logger)
|
492
493
|
false
|
493
494
|
end
|
494
495
|
|
495
496
|
def flush
|
496
497
|
return unless socket
|
497
|
-
|
498
|
+
|
499
|
+
respond_to?(:logger) ? logger.benchmark_debug("#flush") { socket.flush } : socket.flush
|
498
500
|
end
|
499
501
|
|
500
502
|
def closed?
|
@@ -522,7 +524,11 @@ module Net
|
|
522
524
|
return false if socket.nil? || closed?
|
523
525
|
|
524
526
|
if IO.select([socket], nil, nil, 0)
|
525
|
-
|
527
|
+
begin
|
528
|
+
!socket.eof?
|
529
|
+
rescue StandardError
|
530
|
+
false
|
531
|
+
end
|
526
532
|
else
|
527
533
|
true
|
528
534
|
end
|
@@ -544,8 +550,8 @@ module Net
|
|
544
550
|
Policy::Base.factory(policy, servers).each do |address|
|
545
551
|
begin
|
546
552
|
return connect_to_address(address)
|
547
|
-
rescue ConnectionTimeout, ConnectionFailure =>
|
548
|
-
last_exception =
|
553
|
+
rescue ConnectionTimeout, ConnectionFailure => e
|
554
|
+
last_exception = e
|
549
555
|
end
|
550
556
|
end
|
551
557
|
|
@@ -577,7 +583,7 @@ module Net
|
|
577
583
|
@address = address
|
578
584
|
|
579
585
|
# Invoke user supplied Block every time a new connection has been established
|
580
|
-
@on_connect
|
586
|
+
@on_connect&.call(self)
|
581
587
|
end
|
582
588
|
|
583
589
|
# Connect to server
|
@@ -596,21 +602,21 @@ module Net
|
|
596
602
|
rescue Errno::EISCONN
|
597
603
|
# Connection was successful.
|
598
604
|
rescue NonBlockingTimeout
|
599
|
-
raise ConnectionTimeout
|
600
|
-
rescue SystemCallError, IOError =>
|
601
|
-
message = "#connect Connection failure connecting to '#{address
|
605
|
+
raise ConnectionTimeout, "Timed out after #{timeout} seconds trying to connect to #{address}"
|
606
|
+
rescue SystemCallError, IOError => e
|
607
|
+
message = "#connect Connection failure connecting to '#{address}': #{e.class}: #{e.message}"
|
602
608
|
logger.error message if respond_to?(:logger)
|
603
|
-
raise ConnectionFailure.new(message, address.to_s,
|
609
|
+
raise ConnectionFailure.new(message, address.to_s, e)
|
604
610
|
end
|
605
611
|
end
|
606
612
|
|
607
613
|
# Write to the socket
|
608
614
|
def socket_write(data, timeout)
|
609
|
-
if timeout
|
615
|
+
if timeout.negative?
|
610
616
|
socket.write(data)
|
611
617
|
else
|
612
|
-
deadline
|
613
|
-
length
|
618
|
+
deadline = Time.now.utc + timeout
|
619
|
+
length = data.bytesize
|
614
620
|
total_count = 0
|
615
621
|
non_blocking(socket, deadline) do
|
616
622
|
loop do
|
@@ -621,22 +627,23 @@ module Net
|
|
621
627
|
end
|
622
628
|
total_count += count
|
623
629
|
return total_count if total_count >= length
|
630
|
+
|
624
631
|
data = data.byteslice(count..-1)
|
625
632
|
end
|
626
633
|
end
|
627
634
|
end
|
628
635
|
rescue NonBlockingTimeout
|
629
636
|
logger.warn "#write Timeout after #{timeout} seconds" if respond_to?(:logger)
|
630
|
-
raise WriteTimeout
|
631
|
-
rescue SystemCallError, IOError =>
|
632
|
-
message = "#write Connection failure while writing to '#{address
|
637
|
+
raise WriteTimeout, "Timed out after #{timeout} seconds trying to write to #{address}"
|
638
|
+
rescue SystemCallError, IOError => e
|
639
|
+
message = "#write Connection failure while writing to '#{address}': #{e.class}: #{e.message}"
|
633
640
|
logger.error message if respond_to?(:logger)
|
634
|
-
raise ConnectionFailure.new(message, address.to_s,
|
641
|
+
raise ConnectionFailure.new(message, address.to_s, e)
|
635
642
|
end
|
636
643
|
|
637
644
|
def socket_read(length, buffer, timeout)
|
638
645
|
result =
|
639
|
-
if timeout
|
646
|
+
if timeout.negative?
|
640
647
|
buffer.nil? ? socket.read(length) : socket.read(length, buffer)
|
641
648
|
else
|
642
649
|
deadline = Time.now.utc + timeout
|
@@ -648,19 +655,19 @@ module Net
|
|
648
655
|
# EOF before all the data was returned
|
649
656
|
if result.nil? || (result.length < length)
|
650
657
|
logger.warn "#read server closed the connection before #{length} bytes were returned" if respond_to?(:logger)
|
651
|
-
raise ConnectionFailure.new(
|
658
|
+
raise ConnectionFailure.new("Connection lost while reading data", address.to_s, EOFError.new("end of file reached"))
|
652
659
|
end
|
653
660
|
result
|
654
661
|
rescue NonBlockingTimeout
|
655
662
|
logger.warn "#read Timeout after #{timeout} seconds" if respond_to?(:logger)
|
656
|
-
raise ReadTimeout
|
657
|
-
rescue SystemCallError, IOError =>
|
658
|
-
message = "#read Connection failure while reading data from '#{address
|
663
|
+
raise ReadTimeout, "Timed out after #{timeout} seconds trying to read from #{address}"
|
664
|
+
rescue SystemCallError, IOError => e
|
665
|
+
message = "#read Connection failure while reading data from '#{address}': #{e.class}: #{e.message}"
|
659
666
|
logger.error message if respond_to?(:logger)
|
660
|
-
raise ConnectionFailure.new(message, address.to_s,
|
667
|
+
raise ConnectionFailure.new(message, address.to_s, e)
|
661
668
|
end
|
662
669
|
|
663
|
-
class NonBlockingTimeout< ::SocketError
|
670
|
+
class NonBlockingTimeout < ::SocketError
|
664
671
|
end
|
665
672
|
|
666
673
|
def non_blocking(socket, deadline)
|
@@ -668,16 +675,19 @@ module Net
|
|
668
675
|
rescue IO::WaitReadable
|
669
676
|
time_remaining = check_time_remaining(deadline)
|
670
677
|
raise NonBlockingTimeout unless IO.select([socket], nil, nil, time_remaining)
|
678
|
+
|
671
679
|
retry
|
672
680
|
rescue IO::WaitWritable
|
673
681
|
time_remaining = check_time_remaining(deadline)
|
674
682
|
raise NonBlockingTimeout unless IO.select(nil, [socket], nil, time_remaining)
|
683
|
+
|
675
684
|
retry
|
676
685
|
end
|
677
686
|
|
678
687
|
def check_time_remaining(deadline)
|
679
688
|
time_remaining = deadline - Time.now.utc
|
680
|
-
raise NonBlockingTimeout if time_remaining
|
689
|
+
raise NonBlockingTimeout if time_remaining.negative?
|
690
|
+
|
681
691
|
time_remaining
|
682
692
|
end
|
683
693
|
|
@@ -705,13 +715,13 @@ module Net
|
|
705
715
|
rescue Errno::EISCONN
|
706
716
|
# Connection was successful.
|
707
717
|
rescue NonBlockingTimeout
|
708
|
-
raise ConnectionTimeout
|
718
|
+
raise ConnectionTimeout, "SSL handshake Timed out after #{timeout} seconds trying to connect to #{address}"
|
709
719
|
end
|
710
720
|
end
|
711
|
-
rescue SystemCallError, OpenSSL::SSL::SSLError, IOError =>
|
712
|
-
message = "#connect SSL handshake failure with '#{address
|
721
|
+
rescue SystemCallError, OpenSSL::SSL::SSLError, IOError => e
|
722
|
+
message = "#connect SSL handshake failure with '#{address}': #{e.class}: #{e.message}"
|
713
723
|
logger.error message if respond_to?(:logger)
|
714
|
-
raise ConnectionFailure.new(message, address.to_s,
|
724
|
+
raise ConnectionFailure.new(message, address.to_s, e)
|
715
725
|
end
|
716
726
|
|
717
727
|
# Verify Peer certificate
|
@@ -721,20 +731,20 @@ module Net
|
|
721
731
|
|
722
732
|
# Raises Net::TCPClient::ConnectionFailure if the peer certificate does not match its hostname
|
723
733
|
def ssl_verify(ssl_socket, address)
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
734
|
+
return if OpenSSL::SSL.verify_certificate_identity(ssl_socket.peer_cert, address.host_name)
|
735
|
+
|
736
|
+
domains = extract_domains_from_cert(ssl_socket.peer_cert)
|
737
|
+
ssl_socket.close
|
738
|
+
message = "#connect SSL handshake failed due to a hostname mismatch. Request address was: '#{address}'" \
|
739
|
+
" Certificate valid for hostnames: #{domains.map { |d| "'#{d}'" }.join(',')}"
|
740
|
+
logger.error message if respond_to?(:logger)
|
741
|
+
raise ConnectionFailure.new(message, address.to_s)
|
732
742
|
end
|
733
743
|
|
734
744
|
def extract_domains_from_cert(cert)
|
735
|
-
cert.subject.to_a.each
|
745
|
+
cert.subject.to_a.each do |oid, value|
|
736
746
|
return [value] if oid == "CN"
|
737
|
-
|
747
|
+
end
|
738
748
|
end
|
739
749
|
end
|
740
750
|
end
|
data/lib/net/tcp_client.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
require
|
1
|
+
require "socket"
|
2
2
|
# Load SemanticLogger if available
|
3
3
|
begin
|
4
|
-
require
|
4
|
+
require "semantic_logger"
|
5
5
|
rescue LoadError
|
6
6
|
end
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
7
|
+
require "net/tcp_client/version"
|
8
|
+
require "net/tcp_client/address"
|
9
|
+
require "net/tcp_client/exceptions"
|
10
|
+
require "net/tcp_client/tcp_client"
|
11
11
|
|
12
12
|
# @formatter:off
|
13
13
|
module Net
|
14
14
|
class TCPClient
|
15
15
|
module Policy
|
16
|
-
autoload :Base,
|
17
|
-
autoload :Custom,
|
18
|
-
autoload :Ordered,
|
19
|
-
autoload :Random,
|
16
|
+
autoload :Base, "net/tcp_client/policy/base.rb"
|
17
|
+
autoload :Custom, "net/tcp_client/policy/custom.rb"
|
18
|
+
autoload :Ordered, "net/tcp_client/policy/ordered.rb"
|
19
|
+
autoload :Random, "net/tcp_client/policy/random.rb"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/net_tcp_client.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require "net/tcp_client"
|
metadata
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net_tcp_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Net::TCPClient implements resilience features that many developers wish
|
14
14
|
was already included in the standard Ruby libraries.
|
15
15
|
email:
|
16
|
-
- reidmo@gmail.com
|
17
16
|
executables: []
|
18
17
|
extensions: []
|
19
18
|
extra_rdoc_files: []
|
@@ -31,24 +30,12 @@ files:
|
|
31
30
|
- lib/net/tcp_client/tcp_client.rb
|
32
31
|
- lib/net/tcp_client/version.rb
|
33
32
|
- lib/net_tcp_client.rb
|
34
|
-
|
35
|
-
- test/policy/custom_policy_test.rb
|
36
|
-
- test/policy/ordered_policy_test.rb
|
37
|
-
- test/policy/random_policy_test.rb
|
38
|
-
- test/simple_tcp_server.rb
|
39
|
-
- test/ssl_files/ca.key
|
40
|
-
- test/ssl_files/ca.pem
|
41
|
-
- test/ssl_files/localhost-server-key.pem
|
42
|
-
- test/ssl_files/localhost-server.pem
|
43
|
-
- test/ssl_files/no-sni-key.pem
|
44
|
-
- test/ssl_files/no-sni.pem
|
45
|
-
- test/tcp_client_test.rb
|
46
|
-
- test/test_helper.rb
|
47
|
-
homepage: https://github.com/rocketjob/net_tcp_client
|
33
|
+
homepage: https://github.com/reidmorrison/net_tcp_client
|
48
34
|
licenses:
|
49
35
|
- Apache-2.0
|
50
|
-
metadata:
|
51
|
-
|
36
|
+
metadata:
|
37
|
+
rubygems_mfa_required: 'true'
|
38
|
+
post_install_message:
|
52
39
|
rdoc_options: []
|
53
40
|
require_paths:
|
54
41
|
- lib
|
@@ -56,29 +43,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
43
|
requirements:
|
57
44
|
- - ">="
|
58
45
|
- !ruby/object:Gem::Version
|
59
|
-
version: '
|
46
|
+
version: '2.3'
|
60
47
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
48
|
requirements:
|
62
49
|
- - ">="
|
63
50
|
- !ruby/object:Gem::Version
|
64
51
|
version: '0'
|
65
52
|
requirements: []
|
66
|
-
rubygems_version: 3.
|
67
|
-
signing_key:
|
53
|
+
rubygems_version: 3.3.7
|
54
|
+
signing_key:
|
68
55
|
specification_version: 4
|
69
56
|
summary: Net::TCPClient is a TCP Socket Client with built-in timeouts, retries, and
|
70
57
|
logging
|
71
|
-
test_files:
|
72
|
-
- test/ssl_files/localhost-server-key.pem
|
73
|
-
- test/ssl_files/localhost-server.pem
|
74
|
-
- test/ssl_files/ca.pem
|
75
|
-
- test/ssl_files/no-sni-key.pem
|
76
|
-
- test/ssl_files/ca.key
|
77
|
-
- test/ssl_files/no-sni.pem
|
78
|
-
- test/simple_tcp_server.rb
|
79
|
-
- test/test_helper.rb
|
80
|
-
- test/tcp_client_test.rb
|
81
|
-
- test/address_test.rb
|
82
|
-
- test/policy/ordered_policy_test.rb
|
83
|
-
- test/policy/random_policy_test.rb
|
84
|
-
- test/policy/custom_policy_test.rb
|
58
|
+
test_files: []
|