Repository navigation
Make the KvHandle TTL cap configurable per handle - #415
Open
eastagiletracker wants to merge 1 commit into
Open
eastagiletracker wants to merge 1 commit into
eastagiletracker wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR proposes making the
KvHandleTTL cap configurable per handle, so retention windows longer than a year can be written through named KV stores (Fixes #323). We include this PR work along with a full history of your repo at https://eastagiletracker.com/projects/1008. You can sign in with your GitHub ID to claim ownership of the project.What changed and why
KvHandle::validate_ttlrejected every TTL above the hard-codedKvHandle::MAX_TTL(365 days), and sinceKvRegistry::namedhands back aKvHandle(BoundKvStoreis an alias for it), an app with a multi-year retention policy had no way to write through a named store. This implements option 1 from the issue:KvHandlenow carries its ownmax_ttl,KvHandle::newinitialises it toMAX_TTL(so default behaviour is unchanged), and two additive methods expose it:with_max_ttl(self, Duration) -> Selfreturns the handle with a different cap, andmax_ttl(&self)reports the active one. The cap travels with clones.MIN_TTLstill applies, and the over-cap error now names the actual cap instead of a fixed "1 year". Usage:kv.named("events").map(|store| store.with_max_ttl(retention)).No public signature changed or was removed, so existing callers compile and behave as before. The adapters already cope with long TTLs: Axum computes expiry with
checked_addand reports overflow as an internal error (covered by its existingput_bytes_with_ttl_propagates_overflow_as_internal_errortest), Cloudflare passes whole seconds, and Fastly passes theDurationthrough.docs/guide/kv.mdnow mentions the override in the TTL note and the limits table.Reproduction at current HEAD (f717674)
A throwaway integration test against
main, usingNoopKvStore, rejected a two-year TTL:Verification
key_value_store.rs: the default cap equalsMAX_TTL; a raised cap accepts a two-year TTL through bothput_with_ttlandput_bytes_with_ttland the values read back; writes above a custom cap are still rejected (both paths) and nothing is stored; the cap can be lowered; the 60-second floor still applies; clones keep the cap. Changing the comparison back toSelf::MAX_TTLturns three of them red (accepts_ttl_beyond_default_cap,can_lower_the_cap,is_preserved_by_clone) while the controls stay green.cargo test -p edgezero-core --all-targets: 485 passed before, 491 passed after (the 6 new tests), 0 failures.cargo test -p edgezero-adapter-axum --all-targets: 119 passed before and after.cargo clippy -p edgezero-core --all-targets --all-features -- -D warningsis clean,cargo fmt --all -- --checkis clean, andcargo check --workspace --all-targetspasses.How this was managed
This work was tracked as https://eastagiletracker.com/projects/1008/stories/1318615 on https://eastagiletracker.com/projects/1008, a board imported from this repository's 378 issues and pull requests and used to manage this change.
If you'd rather not receive contributions like this, reply
no-more-prson this pull request and we won't open any further ones on your repositories.Lawrence W. Sinclair
CEO / East Agile
linkedin.com/in/lwsinclair/
eastagile.com