Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support history #7

Open
tomchristie opened this issue Feb 26, 2020 · 1 comment
Open

Support history #7

tomchristie opened this issue Feb 26, 2020 · 1 comment

Comments

@tomchristie
Copy link
Member

Something that'd be really valuable would be to allow subscriptions to start up with some initial history.

For example:

  • Subscribe to "logs", with the last 1000 records, so that a front-end can display a log console, that's populated with the latest set of logs.
  • Subscribe to "http-stats" with the last 24 hours of records, so that a front-end can display a realtime status monitoring graph, that's populated with a window of the latest history.

Not all backends will support this, but Redis Streams, and Apache Kafka do. I think the implementation may be a bit fiddly to get right, but before we even get there let's discuss the API.

One option here might be...

async with broadcaster.subscribe("logs", history=1000):
    ...

async with broadcaster.subscribe("http-stats", history=timedelta(hours=24)):
    ...
  • Are there any API alternatives we ought to be considering?
  • Would Kafka and Redis Streams properly support both the int and the timedelta styles, and what commands would we need to be mapping them onto?
@woile
Copy link
Contributor

woile commented Feb 26, 2020

kafka has offsets so it should be possible, also for time it has offsets_for_times which returns the offset inside that timestamp. It's a bit tricky because of the kafka partitions, but I'll investigate further.

And redis stream have xrange but not sure if they support datetime.

Another thing to think about is how to retrieve everything. Let's say you have a topic where the content expires daily "notifications", so you want to read it all, how would it look like?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants