Skip to content

Commit

Permalink
synchronous producer: Add message acknowledgement timeout, default to…
Browse files Browse the repository at this point in the history
… 5 second
  • Loading branch information
Soulou committed Jan 27, 2019
1 parent fd6d711 commit 1e2530f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/nsq/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def initialize(opts = {})
@host = opts[:host] || (raise ArgumentError, 'host is required')
@port = opts[:port] || (raise ArgumentError, 'port is required')
@synchronous = opts[:synchronous] || false
@ok_timeout = opts[:ok_timeout] || 5
@queue = opts[:queue]
@topic = opts[:topic]
@channel = opts[:channel]
Expand Down Expand Up @@ -160,7 +161,9 @@ def write(raw)
result: result,
})
if result
value = result.pop
value = Timeout::timeout @ok_timeout do
result.pop
end
raise value if value.is_a?(Exception)
end
end
Expand Down

0 comments on commit 1e2530f

Please sign in to comment.