Closed bradgessler closed 8 years ago
If this looks good I'll cut a 1.3.6 gem and yank 1.3.5.
How about something like this?
def remaining_messages
messages.last(remaining_message_count)
end
private
def remaining_message_count
count = @channel_sequence - @consumer_sequence
if count < 0
# UNEXPECTED: Somehow the sequence is ahead of the channel.
# It is likely a bug in the consumer, but we'll assume
# the consumer has all the messages.
0
elsif count > @message_list.size
# Consumer is under water since the last request. Just send the most recent message.
1
else
count
end
end
Yeah, that's way more clear.
I put my suggestion into this PR: https://github.com/firehoseio/firehose/pull/66
Closing in favor of https://github.com/firehoseio/firehose/pull/66
@thoughtless I believe this fixes all the behavioral issues you brought to light in https://github.com/firehoseio/firehose/commit/b7e412a17d7262c9d04f5115c5a61f0603309f1f