-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use nonblocking write #39
Conversation
When detect EAGAIN or EWOULDBLOCK, `:wait_writeable` is true: store the data in buffer and try to write next time. `:wait_writeable` is false: Raise IO::EAGAINWaitWritable
I've not able to produce the situation explaining in #30 because fluentd is very fast and robust. Run fake-server.rb and t.rb. In previous version, In this PR, t.rb does not block while writing logs anymore. fake-server.rb: require "socket"
server = TCPServer.open("localhost", 24224)
addr = server.addr
addr.shift
puts "server is on #{addr.join(":")}"
loop do
Thread.start(server.accept) do |s|
puts "#{s} is accepted"
while s.gets
print "#{$_.size}/"
sleep 30
end
puts "#{s} is gone"
s.close
end
end t.rb: require "fluent-logger"
Fluent::Logger::FluentLogger.open(nil, :host=>'localhost', :port=>24224, :wait_writeable => true)
a = []
start = Time.now
100.times do |i|
a << Thread.start(i, j = 0) do
loop do
Fluent::Logger.post("myapp.access", ENV.to_hash)
j += 1
#puts "#{i},#{j}" if j % 1000 == 0
print "#{i},#{j}/"
end
end
end
a.each(&:join)
p :done
p Time.now - start |
+1 |
Does anyone test this patch? |
Are there any updates or plans to apply this patch? |
We wait a response from users but no response. |
Thank you |
Release v0.8.0. Check https://github.com/fluent/fluent-logger-ruby#nonblocking-write |
No description provided.