henomis<p>🎭 To block or not to block, that is the question.</p><p>Let’s suppose we have a stream of events and a pull consumer. The consumer has two methods to fetch: the first is gonna block until it receives something, and the second has a timeout to unblock. My personal rule of thumb is:</p><p>- if you need to synchronously consume a single event then process it: use the blocking one, as you’re using the stream like a FIFO queue.<br>- if you need to fetch ‘n’ events: use the non-blocking one, you might have no warranty that the stream contains (or is able to send) the expected amount of events.</p><p><a href="https://mastodon.bsd.cafe/tags/asynchronous" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>asynchronous</span></a> <a href="https://mastodon.bsd.cafe/tags/distributedsystems" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>distributedsystems</span></a> <a href="https://mastodon.bsd.cafe/tags/developerslife" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>developerslife</span></a></p>