From 2169eb4646d882250689e07b37b3d3fde895848d Mon Sep 17 00:00:00 2001 From: Petro <2592462+Kazmirchuk@users.noreply.github.com> Date: Sat, 23 Dec 2023 16:20:11 +0100 Subject: [PATCH] bump version to 3.0 - added ErrNotJSMessage --- JsAPI.md | 5 +++-- KvAPI.md | 14 ++++++++++---- examples/kv_mirror.tcl | 2 ++ jet_stream.tcl | 5 ++++- nats_client.tcl | 2 +- pkgIndex.tcl | 4 ++-- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/JsAPI.md b/JsAPI.md index dbf54b2..7bf50b8 100644 --- a/JsAPI.md +++ b/JsAPI.md @@ -428,8 +428,9 @@ In addition to all [core NATS errors](CoreAPI.md#error-handling), the `jet_strea | ErrBucketNotFound | from ErrStreamNotFound | Bucket does not exist | | ErrMsgNotFound | 404/10037 | Message not found in a stream | | ErrKeyNotFound | from ErrMsgNotFound | Key not found in a bucket | -| ErrJSResponse | | Other JetStream error. `code` and `err_code` is passed in the Tcl error code and `description` is used for the error message. | - +| ErrJSResponse | any| Other JetStream error. `code` and `err_code` is passed in the Tcl error code and `description` is used for the error message. | +| ErrNotJSMessage | N/A | Thrown by [nats::metadata](#natsmetadata-message) when a message didn't come from a consumer | + See also "Error Response" in [ADR-1](https://github.com/nats-io/nats-architecture-and-design/blob/main/adr/ADR-1.md#error-response). [^1]: You can specify the `-expires` option explicitly (ms), but this is an advanced use case and normally should not be needed. diff --git a/KvAPI.md b/KvAPI.md index 250bcdc..019a76c 100644 --- a/KvAPI.md +++ b/KvAPI.md @@ -207,13 +207,19 @@ Returns a KV origin configuration to be used with [create_kv_aggregate](#js-crea - `-stream str` - in case the origin is not an actual bucket, but a mirror, you need to pass the stream/mirror name as well [^5] - `-keys list` - optional filter -If the origin bucket is in another JetStream domain or account, you need two more options: -- `-api APIPrefix` (required) - the subject prefix that imports the other account/domain -- `-deliver deliverySubject` (optional) - the delivery subject to use for the push consumer +If the origin bucket is in another JetStream domain: +- `-domain str` - domain name +If the origin bucket is in another account: +- `-api APIPrefix` - the subject prefix that imports the other account + +In both cases you can also specify: +- `-deliver deliverySubject` (optional) - the delivery subject to use for the push consumer/KV watcher + +*Note*: `-domain` is a shorthand option equivalent to `-api "\$JS.$domain.API"` Example of creating a writable KV aggregate sourcing a subset `new.>` of keys/values from another bucket `HUB_BUCKET` located in the `hub` domain: ```Tcl -set origin [nats::make_kv_origin -bucket HUB_BUCKET -keys new.> -api "\$JS.hub.API"] +set origin [nats::make_kv_origin -bucket HUB_BUCKET -keys new.> -domain hub] set kv [$js create_kv_aggregate LEAF_KV true [list $origin] -description "writable filtered KV aggregate"] ``` See also [nats::make_stream_source](JsApi.md#natsmake_stream_source--option-value). diff --git a/examples/kv_mirror.tcl b/examples/kv_mirror.tcl index da22af5..e0b499f 100644 --- a/examples/kv_mirror.tcl +++ b/examples/kv_mirror.tcl @@ -23,12 +23,14 @@ set conn_hub [nats::connection new "HUB"] $conn_hub configure -servers nats://localhost:4222 -user acc -password acc $conn_hub connect set js_hub [$conn_hub jet_stream -timeout 1000] +puts "Check JS domain: [dict get [$js_hub account_info] domain]" puts "Connecting to the 'leaf' NATS..." set conn_leaf [nats::connection new "LEAF"] $conn_leaf configure -servers nats://localhost:4111 -user acc -password acc $conn_leaf connect set js_leaf [$conn_leaf jet_stream -timeout 1000] +puts "Check JS domain: [dict get [$js_leaf account_info] domain]" puts "Create a KV bucket in the hub..." set kv_hub [$js_hub create_kv_bucket HUB_BUCKET -history 64] diff --git a/jet_stream.tcl b/jet_stream.tcl index a767d88..a85bfa5 100644 --- a/jet_stream.tcl +++ b/jet_stream.tcl @@ -1232,9 +1232,12 @@ proc ::nats::_ns2ms {dict_name args} { # metadata is encoded in the reply field: # V1: $JS.ACK......