feat: add local KV instance support with --local flag#5
Closed
frontmesh wants to merge 2 commits into
Closed
Conversation
- Add support for switching between local and remote KV instances - Local KV defaults to http://localhost:8787 (wrangler dev default) - Remote KV uses https://api.cloudflare.com/client/v4 (production API) - Add -l/--local flag to CLI for easy switching - Update ClientConfig with is_local field and base_url() method - Add tests for local/remote endpoint switching - All existing tests pass
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.
Feature: Local KV Instance Support
Problem
When running
wrangler devfor local development, users had no way to easily post data to the local KV instance. The namespace ID is the same for both local and remote, making it confusing which endpoint is being used.Solution
Add a
--local/-lflag that switches between local and remote KV endpoints:-l):http://localhost:8787(wrangler dev)-l):https://api.cloudflare.com/client/v4(production)Usage Examples
Changes
--local/-lflag to CLIClientConfigto support local/remote switchingdocs/LOCAL_KV_DEVELOPMENT.mdPrerequisites
wrangler devmust be running for local operationsTesting
Files Changed
crates/cloudflare-kv/src/types.rs- Addedis_localandbase_url()methodcrates/cloudflare-kv/src/client.rs- Added local/remote endpoint testscrates/cfkv/src/cli.rs- Added--localflag to CLIcrates/cfkv/src/main.rs- Apply local flag to KvClient configdocs/LOCAL_KV_DEVELOPMENT.md- New comprehensive development guide