I want to be able to read from Kafka indefinitely in an infinite loop. When developing locally on my laptop, I often have no messages to read. I'd like to just block the process calling #fetch by rescuing timeouts and rerunning #fetch. However, the exception class ConnectionFailedError is raised in place of not only TimeoutException, but also Errno::ECONNRESET and SocketError.
The consequence for me is that my spin loop can't distinguish between network errors and a partition that simply has no messages to send down to the client. Is there another way I should be doing this, e.g. detecting if I have no messages before I call fetch?
I want to be able to read from Kafka indefinitely in an infinite loop. When developing locally on my laptop, I often have no messages to read. I'd like to just block the process calling
#fetch
by rescuing timeouts and rerunning#fetch
. However, the exception classConnectionFailedError
is raised in place of not onlyTimeoutException
, but alsoErrno::ECONNRESET
andSocketError
.The consequence for me is that my spin loop can't distinguish between network errors and a partition that simply has no messages to send down to the client. Is there another way I should be doing this, e.g. detecting if I have no messages before I call
fetch
?