question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow reader to detect when it's caught up with writers

See original GitHub issue

Context

We have recently introduced the concept of topic “Reader” as an alternative to the traditional pub-sub consumer abstraction.

A common followup request has been to have a way to identify when the reader has reached the last published entry on the topic.

There is no currently direct way to achieve that and using readNext(timeout) doesn’t help because in case the client is not connected to broker, it doesn’t mean that there are no more messages to read.

There are a few workaround that are not easy or desirable (eg: terminating the topic, or using HTTP admin API to check the backlog on the reader).

Since this is a common theme, we should have a good way to handle this.

Possible solutions

  1. When creating a reader, we need a way to tell the current (minimum) amount of messages that it can read. We have that information in the broker, we just need a way to bubble that back to client lib (without breaking API).

  2. Provide a way to check if there are messages available to read. Eg.:

    while (reader.hasNext()) {
        Message msg = reader.readNext();
    }
    

    The tricky part here is that we don’t want to ask the broker each time, but rather we should cache that information in client and check periodically. (eg: I check now and it says there are 100 messages, I can check back after those 100 have been read).

  3. In some cases, it might desirable to start multiple readers in parallel on the same topic, in a “time-segmented” way. For example, if you have 1M message in a single topic, starting 10 readers at different message ids and each of them reading 100K messages in parallel. For this, we would require a way to specify an offset on the reader start message id (eg: messageId + 300K messages).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
zhaijackcommented, Jan 4, 2018

If it is OK, I would like to contribute on this issue

0reactions
sijiecommented, Apr 25, 2018

This fix was contributed by @zhaijack

Read more comments on GitHub >

github_iconTop Results From Across the Web

This Simple Principle Will Solve Your Show, Don't Tell Problems
Writers who “tell, don't show” get caught up in describing causes not effects. ... because it allows readers to imagine what's going on...
Read more >
Show Don't Tell: How to Write Effective Exposition - MasterClass
“Show, don't tell” is a writing technique that allows the reader to experience expository details of the story through actions, sensory details, ...
Read more >
How to Grab Your Reader's Attention - Copyblogger
If you're wondering how to grab readers' attention, check out these techniques that make your writing memorable and thought-provoking.
Read more >
Tips For Effective Proofreading - Writing Center - UA Little Rock
Try reading backwards, a sentence at a time. This will help you focus on the sentences, rather than getting caught up in the...
Read more >
Don't Make These Mistakes When Writing Dialogue
If there are only two characters in a scene, it's easy for the reader to keep track. Mistake #6: Allowing the Characters to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found