Skip to content

Commit

Permalink
Initial support for per-message TTLs (#6272)
Browse files Browse the repository at this point in the history
This is an incomplete but somewhat-working implementations of
per-message TTLs.

Notes:
- Adds `AllowMsgTTL` to stream config;
- Parses the `Nats-TTL` message header as a parsable duration, or if
not, second precision;
- Bumps the `index.db` magic version so that we can add a new field for
tracking how many TTL'd messages are in each message block (means that
`index.db` needs to be rebuilt if downgrading);
- Adds a new `thw.db` to store the timed hash wheel state, and tries to
rebuild it from a linear scan if it is missing or out-of-date.

Future work:
- Memory store support;
- Expires "never" including not aging out with MaxAge;
- Ability to update a TTL for a message;
- Decide what we want to do for enabling/disabling TTL support;
- Decide how mirroring/sourcing streams will handle TTL headers.

Signed-off-by: Neil Twigg <neil@nats.io>
  • Loading branch information
derekcollison authored Dec 24, 2024
2 parents 0ae722e + 6ea9fe0 commit 1a0d55f
Show file tree
Hide file tree
Showing 15 changed files with 1,109 additions and 407 deletions.
10 changes: 10 additions & 0 deletions server/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -1628,5 +1628,15 @@
"help": "",
"url": "",
"deprecates": ""
},
{
"constant": "JSMessageTTLInvalidErr",
"code": 400,
"error_code": 10165,
"description": "invalid per-message TTL",
"comment": "",
"help": "",
"url": "",
"deprecates": ""
}
]
Loading

0 comments on commit 1a0d55f

Please sign in to comment.