Skip to content

Commit e2926c2

Browse files
committed
Use timeout parameters when run on supported Ruby version
Signed-off-by: Shizuo Fujita <[email protected]>
1 parent 5faccbe commit e2926c2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

fluent-logger.gemspec

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ Gem::Specification.new do |gem|
2121
gem.require_paths = ['lib']
2222
gem.license = "Apache-2.0"
2323

24-
gem.required_ruby_version = '>= 3.0'
25-
2624
gem.add_dependency "msgpack", ">= 1.0.0", "< 2"
2725

2826
# logger gem that isn't default gems as of Ruby 3.5

lib/fluent/logger/fluent_logger.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,11 @@ def create_socket!
173173
if @socket_path
174174
@con = UNIXSocket.new(@socket_path)
175175
else
176-
@con = TCPSocket.new(@host, @port, connect_timeout: @connect_timeout, resolv_timeout: @resolv_timeout)
176+
if supported_timeout?
177+
@con = TCPSocket.new(@host, @port, connect_timeout: @connect_timeout, resolv_timeout: @resolv_timeout)
178+
else
179+
@con = TCPSocket.new(@host, @port)
180+
end
177181
if @tls_options
178182
context = OpenSSL::SSL::SSLContext.new
179183
if @tls_options[:insecure]
@@ -381,6 +385,10 @@ def wait_writeable?(e)
381385
true
382386
end
383387
end
388+
389+
def supported_timeout?
390+
@supported_timeout ||= Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
391+
end
384392
end
385393
end
386394
end

0 commit comments

Comments
 (0)