nri-redis: add handlerWithoutNamespace constructor#154
Merged
Conversation
Adds a deliberately-named opt-out for callers who need to read or write Redis keys that aren't owned by this app and so don't follow the library's namespace convention. The existing `handler` / `handlerAutoExtendExpire` constructors continue to require a namespace, so opting out remains visible at the call site. Internally the namespace field on `Handler'` becomes `Maybe Text`; a small `namespacePrefix` helper produces the `ns:` prefix (or empty string) consumed by `query`, `transaction`, and `eval`. Tests pin down the contract: writes go to literal keys, reads don't prefix, eval script keys aren't rewritten, and `foldWithScan` returns keys verbatim. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an explicit opt-out constructor for Redis key namespacing, allowing callers to intentionally operate on “literal” (non-app-owned) keys while keeping the existing namespaced constructors unchanged.
Changes:
- Add
handlerWithoutNamespaceconstructor and re-export it fromRedis. - Make the internal handler namespace optional (
Maybe Text) and centralize prefixing logic vianamespacePrefix. - Add a dedicated test suite for the no-namespace contract and update golden observability outputs + package version/changelog.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| nri-redis/src/Redis/Handler.hs | Introduces handlerWithoutNamespace and threads optional namespace through handler acquisition. |
| nri-redis/src/Redis/Internal.hs | Converts handler namespace to Maybe Text and updates query/transaction/eval to use a shared prefix helper. |
| nri-redis/src/Redis.hs | Re-exports handlerWithoutNamespace from the public Redis module. |
| nri-redis/test/Helpers.hs | Adds a noNamespaceHandler to the test harness. |
| nri-redis/test/Spec/Redis.hs | Adds no-namespace behavior tests and updates helper addNamespace for Maybe Text. |
| nri-redis/test/golden-results-9.8/* | Updates golden traces for the new version and shifted source locations. |
| nri-redis/package.yaml | Bumps package version to 0.4.1.0. |
| nri-redis/nri-redis.cabal | Bumps package version to 0.4.1.0. |
| nri-redis/CHANGELOG.md | Documents the new handlerWithoutNamespace API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bcardiff
approved these changes
May 21, 2026
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.
Adds a deliberately-named opt-out for callers who need to read or write Redis keys that aren't owned by this app and so don't follow the library's namespace convention. The existing
handler/handlerAutoExtendExpireconstructors continue to require a namespace, so opting out remains visible at the call site.Internally the namespace field on
Handler'becomesMaybe Text; a smallnamespacePrefixhelper produces thens:prefix (or empty string) consumed byquery,transaction, andeval.Tests pin down the contract: writes go to literal keys, reads don't prefix, eval script keys aren't rewritten, and
foldWithScanreturns keys verbatim.