Add JetStream KV bucket support (v2.1.0) - #35
Merged
Merged
Conversation
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.
Summary
Adds first-class support for NATS JetStream KV buckets to the Messenger, following the existing driver architecture.
New driver hierarchy (all under
MsgDriver):{"data", "meta"}envelopes —putvalidates against schemas, reading a foreign (non-serverish) entry raisesMessengerKvMalformedinstead of returning garbage. The only protocol-forced exception: KV delete/purge tombstones carry no payload and surface as(None, meta)withmeta['kv']['operation']set to'DEL'/'PURGE'.meta['kv']: bucket, key, revision, operation, created.ConnectionJetStream.ensure_kv_bucket()— buckets are not created on the fly by default (consistent with stream philosophy); drivers opt in viacreate_bucket=True+bucket_config.Messenger.get_kvstore / get_kvreader / get_kvsubscriber, module-levelget_kvstore/get_kvreader/get_kvsubscriberand one-shotkv_put/kv_get.MessengerKvBucketNotFound,MessengerKvKeyNotFound,MessengerKvMalformed.MsgKvReader, the background-task machinery only inMsgKvSubscriber— linear hierarchy prepared for a futureMsgKvDocumentReader(LiveDocument over a bucket).Version bumped to 2.1.0 (new feature, backward compatible).
Testing
tests/test_messenger_kv.py(put/get round-trip, delete, keys/history, malformed entry, missing bucket, one-shot helpers, watch iteration incl. delete markers, callback subscriber).Related: #34 (shared
Event()default inMsgCallbackSubscriber, noticed while implementingMsgKvSubscriber).🤖 Generated with Claude Code
https://claude.ai/code/session_01HfMGwatJe81U9aekr51R7f