Skip to content

nri-redis: add handlerWithoutNamespace constructor#154

Merged
waj merged 1 commit into
trunkfrom
redis-without-namespace
May 21, 2026
Merged

nri-redis: add handlerWithoutNamespace constructor#154
waj merged 1 commit into
trunkfrom
redis-without-namespace

Conversation

@waj
Copy link
Copy Markdown
Member

@waj waj commented May 19, 2026

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.

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>
Copilot AI review requested due to automatic review settings May 19, 2026 18:12
@waj waj requested a review from omnibs May 19, 2026 18:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 handlerWithoutNamespace constructor and re-export it from Redis.
  • Make the internal handler namespace optional (Maybe Text) and centralize prefixing logic via namespacePrefix.
  • 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.

@waj waj requested review from a team and removed request for omnibs May 21, 2026 11:46
@waj waj added this pull request to the merge queue May 21, 2026
Merged via the queue into trunk with commit 92d8415 May 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants