Skip to content

Commit ee3f0d6

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

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ If `false`, `Logger#post` raises an error when nonblocking write gets `EAGAIN` (
150150

151151
#### connect_timeout (Integer)
152152

153-
Specify timeout in seconds from connecting. Default: `nil`
153+
Specify timeout in seconds from connecting. This parameter will be avail with Ruby 3.0 or above. Default: `nil`
154154

155155
#### resolve_timeout (Integer)
156156

157-
Specify timeout in seconds from when the hostname resolution starts. Default: `nil`
157+
Specify timeout in seconds from when the hostname resolution starts. This parameter will be avail with Ruby 3.0 or above. Default: `nil`
158158

159159
#### buffer_overflow_handler (Proc)
160160

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)