feat: Add first-class Valkey support with GLIDE-backed store#437
Open
janisto wants to merge 2 commits intofastify:mainfrom
Open
feat: Add first-class Valkey support with GLIDE-backed store#437janisto wants to merge 2 commits intofastify:mainfrom
janisto wants to merge 2 commits intofastify:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds first-class Valkey support to @fastify/rate-limit by introducing a new valkey configuration option backed by a GLIDE-scripted ValkeyStore, plus documentation/examples and new test coverage.
Changes:
- Add
ValkeyStoreimplementation using@valkey/valkey-glidescripting APIs and wire it into plugin initialization viasettings.valkey. - Add runtime validation to enforce mutual exclusivity between
store,redis, andvalkey. - Extend TypeScript types, docs, examples, and add unit + integration tests for Valkey behavior.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
index.js |
Adds valkey store selection and validates mutually exclusive store options. |
store/ValkeyStore.js |
New GLIDE-backed store implementation using cached script invocation. |
types/index.d.ts |
Adds FastifyRateLimitValkeyClient, adjusts option types (redis to unknown, valkey added). |
types/index.test-d.ts |
Adds type-level coverage for valkey option and client interface. |
test/valkey-store.test.js |
Unit tests for ValkeyStore key prefixing, child behavior, caching, and error forwarding. |
test/valkey-rate-limit.test.js |
Plugin-level tests for valkey option and new mutual exclusivity validation. |
test/valkey-real-rate-limit.test.js |
Real integration tests against a running Valkey backend (GLIDE client). |
example/example-valkey-direct.mjs |
Example using a directly managed GLIDE client. |
example/example-fastify-valkey-glide.mjs |
Example using @fastify/valkey-glide to supply the resolved client. |
README.md |
Documents Valkey usage, installation guidance, and examples. |
package.json |
Adds optional peer + dev dependency on @valkey/valkey-glide and a local valkey docker script. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+45
to
+46
| err.message = 'Valkey support requires @valkey/valkey-glide to be installed' | ||
| throw err |
Comment on lines
+17
to
+20
| const VALKEY_ADDRESS = { | ||
| host: '127.0.0.1', | ||
| port: Number(process.env.VALKEY_PORT || 6380) | ||
| } |
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 first-class Valkey support to @fastify/rate-limit through a new valkey option backed by a dedicated ValkeyStore that uses @valkey/valkey-glide scripting APIs. It keeps the existing Redis path unchanged, adds runtime validation for mutually exclusive storage options, and updates the public type surface with a structural Valkey client interface.
It also adds documentation and examples for both direct GLIDE clients and @fastify/valkey-glide, plus expanded test coverage for Valkey behavior including ban, skipOnError, throw-on-error, continueExceeding, exponentialBackoff, route-scoped limits, and createRateLimit(). Verification now runs Redis and Valkey integration backends on separate ports so both suites can execute without cross-test interference.
Close #436
See fastify/fastify-valkey-glide#33
Checklist
npm run test && npm run benchmark --if-presentand the Code of conduct