Skip to content

Commit

Permalink
Merge pull request #559 from nats-io/kv_sub_pending_limits
Browse files Browse the repository at this point in the history
[FIXED] KeyValue: set watcher pending limit to unlimited
  • Loading branch information
kozlovic committed Jul 18, 2022
2 parents 10ff89d + 2d0d81f commit b1b81b1
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 b1b81b1

Please sign in to comment.