Skip to content

Commit

Permalink
[FIXED] KeyValue: set watcher pending limit to unlimited
Browse files Browse the repository at this point in the history
Since internal subscription is not currently exposed, setting
the subscription limit to unlimited.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
  • Loading branch information
kozlovic committed Jul 15, 2022
1 parent 10ff89d commit 2d0d81f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/kv.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ kvStore_Watch(kvWatcher **new_watcher, kvStore *kv, const char *key, kvWatchOpti
w->ignoreDel = true;
}
s = js_SubscribeSync(&(w->sub), kv->js, natsBuf_Data(&buf), NULL, &so, NULL);
IFOK(s, natsSubscription_SetPendingLimits(w->sub, -1, -1));
if (s == NATS_OK)
{
natsSubscription *sub = w->sub;
Expand Down
8 changes: 8 additions & 0 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -28440,6 +28440,8 @@ test_KeyValueWatch(void)
kvWatcher *w = NULL;
kvEntry *e = NULL;
natsThread *t = NULL;
int plc = 0;
int plb = 0;
kvConfig kvc;
int64_t start;

Expand Down Expand Up @@ -28551,6 +28553,12 @@ test_KeyValueWatch(void)
s = kvStore_Watch(&w, kv, "t.*", NULL);
testCond(s == NATS_OK);

test("Check pending limits: ");
natsMutex_Lock(w->mu);
s = natsSubscription_GetPendingLimits(w->sub, &plc, &plb);
natsMutex_Unlock(w->mu);
testCond((s == NATS_OK) && (plc == -1) && (plb == -1));

testCond(_expectUpdate(w, "t.name", "ik", 8));
testCond(_expectUpdate(w, "t.age", "49", 10));
testCond(_expectInitDone(w));
Expand Down

0 comments on commit 2d0d81f

Please sign in to comment.