Skip to content

Conversation

@mtmk
Copy link
Collaborator

@mtmk mtmk commented Jul 22, 2025

Adds transparent key encoding/decoding for NATS KV stores, ported from orbit.go's kvcodec package.

Features:

  • INatsKeyCodec / INatsFilterableKeyCodec interfaces for custom codecs
  • NatsBase64KeyCodec - URL-safe Base64 encoding (handles special characters in keys)
  • NatsPathKeyCodec - translates /path/style keys to NATS .subject.style
  • NatsKeyChainCodec - compose multiple codecs
  • NatsKVCodecStore - wraps INatsKVStore with codec support
  • Extension methods: WithBase64Keys(), WithPathKeys(), WithKeyCodec()

Usage:

using Synadia.Orbit.KeyValueStore.Extensions.Codecs;

// Base64 encoding for keys with special characters
var store = rawStore.WithBase64Keys();

// Path-style keys: "/users/123" → "_root_.users.123"
var store = rawStore.WithPathKeys();

mtmk added 3 commits July 22, 2025 18:41
Introduced a new project for Key-Value store extensions with initial files, including a class definition (`NatsKVEncodedStore`), project configuration targeting .NET 8.0, and versioning details (`1.0.0-preview.1`). Updated the solution file to include the new project.
# Conflicts:
#	orbit.net.sln
…ensions`

Introduced key codec implementations (`PathKeyCodec`, `Base64KeyCodec`, `NoOpKeyCodec`) and their integration into the Key-Value store. Added extension methods for applying codecs (`WithBase64Keys`, `WithPathKeys`) and extensive unit tests to validate codec behaviors with encoded keys, filters, and operations. Removed unused `NatsKVEncodedStore` class.
@mtmk mtmk changed the title Add Synadia.Orbit.KeyValueStore.Extensions project with basic setup Add KV key codec support for KeyValueStore Extensions Jan 15, 2026
@mtmk mtmk marked this pull request as ready for review January 15, 2026 11:59
mtmk added 3 commits January 15, 2026 12:00
Expanded `PACKAGE.md` with examples and descriptions of key codecs (`Base64`, `Path`, `Custom`) and their usage. Added unit tests for `Base64KeyCodec` and `PathKeyCodec`, ensuring proper encoding/decoding behaviors and compatibility with complex key scenarios.
…mentation

Expanded `PACKAGE.md` and included new examples demonstrating `ROT13KeyCodec`, chaining of `Path` and `Base64` codecs, and other advanced key codecs. Added related project references and a comprehensive `ExampleKV.cs` file for practical usage scenarios.
@mtmk mtmk merged commit 1d1ca7e into main Jan 16, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants