Skip to content
New issue

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

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

Already on GitHub? # to your account

Always retain last message for each subject in a stream #5811

Open
SomeshDaga opened this issue Aug 20, 2024 · 0 comments
Open

Always retain last message for each subject in a stream #5811

SomeshDaga opened this issue Aug 20, 2024 · 0 comments
Labels
proposal Enhancement idea or proposal stale This issue has had no activity in a while

Comments

@SomeshDaga
Copy link

Proposed change

Add a --keep-last-msg-per-subject flag to the nats server configuration i.e. nats stream add --keep-last-msg-per-subject <more-options> <stream> that works with all limits-based message retention policies (i.e time-based, size-based, count-based).

Use case

Stream limits options (e.g. max-age, max-bytes, max-msgs etc.) mostly seem to operate on a per stream basis. The exception is the max-msgs-per-subject which allows for a per subject based limit.

It would be nice to have the capability to always retain the last message on all given subjects in a stream while setting a time-based message retention policy i.e. delete all messages past an age of 10 mins except the last.

A use case of this can be as follows:

  • We want to record changes to a configuration (stored in a nats subject) and keep a history for a certain period of time e.g. 5 days (specified by the --max-age flag)
  • We always want to be able to fetch the last configuration to initialize our long-running application (which may run for weeks on end) whenever it restarts

Contribution

Yes, I can contribute to this feature

@SomeshDaga SomeshDaga added the proposal Enhancement idea or proposal label Aug 20, 2024
@github-actions github-actions bot added the stale This issue has had no activity in a while label Oct 16, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
proposal Enhancement idea or proposal stale This issue has had no activity in a while
Projects
None yet
Development

No branches or pull requests

1 participant