From abc25600c2d20b4d2ee5c2cbe023e42ebd47a60f Mon Sep 17 00:00:00 2001 From: Alberto Ricart Date: Tue, 6 Sep 2022 14:04:02 -0500 Subject: [PATCH] [FEAT] allow `mirror_direct` option on StreamConfig --- nats-base-client/types.ts | 4 ++++ tests/jsm_test.ts | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/nats-base-client/types.ts b/nats-base-client/types.ts index 75c647a3..85ea9b58 100644 --- a/nats-base-client/types.ts +++ b/nats-base-client/types.ts @@ -1785,6 +1785,10 @@ export interface StreamUpdateConfig { * Allow higher performance, direct access to get individual messages via the $JS.DS.GET API */ "allow_direct": boolean; + /** + * Allow higher performance, direct access to get individual messages via the $JS.DS.GET API + */ + "mirror_direct": boolean; /** * Rules for republishing messages from a stream with subject mapping * onto new subjects for partitioning and more diff --git a/tests/jsm_test.ts b/tests/jsm_test.ts index 54c24a60..37ddcab6 100644 --- a/tests/jsm_test.ts +++ b/tests/jsm_test.ts @@ -1377,3 +1377,36 @@ Deno.test("jsm - consumer name apis are not used on old servers", async () => { await cleanup(ns, nc); }); + +Deno.test("jsm - mirror_direct options", async () => { + const { ns, nc } = await setup( + jetstreamServerConf({}, true), + ); + + if (await notCompatible(ns, nc, "2.9.0")) { + return; + } + + const jsm = await nc.jetstreamManager(); + let si = await jsm.streams.add({ + name: "A", + allow_direct: true, + subjects: ["a.*"], + max_msgs_per_subject: 1, + }); + assertEquals(si.config.allow_direct, true); + + si = await jsm.streams.add({ + name: "B", + allow_direct: true, + mirror_direct: true, + mirror: { + name: "A", + }, + max_msgs_per_subject: 1, + }); + assertEquals(si.config.allow_direct, true); + assertEquals(si.config.mirror_direct, true); + + await cleanup(ns, nc); +});