From 1b3f7a5dfabdf662f319e74511bfcc544fd51ac4 Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Thu, 18 May 2023 17:04:11 +0600 Subject: [PATCH] Update XINFO CONSUMERS reply with inactive field. --- .../clients/jedis/resps/StreamConsumersInfo.java | 16 +++++++++++++--- .../commands/jedis/StreamsCommandsTest.java | 5 ++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/redis/clients/jedis/resps/StreamConsumersInfo.java b/src/main/java/redis/clients/jedis/resps/StreamConsumersInfo.java index e493cc4bcc..7938449d5c 100644 --- a/src/main/java/redis/clients/jedis/resps/StreamConsumersInfo.java +++ b/src/main/java/redis/clients/jedis/resps/StreamConsumersInfo.java @@ -13,10 +13,12 @@ public class StreamConsumersInfo { public static final String NAME = "name"; public static final String IDLE = "idle"; public static final String PENDING = "pending"; + public static final String INACTIVE = "inactive"; private final String name; private final long idle; private final long pending; + private final Long inactive; private final Map consumerInfo; /** @@ -26,9 +28,9 @@ public StreamConsumersInfo(Map map) { consumerInfo = map; name = (String) map.get(NAME); - idle = (long) map.get(IDLE); - pending = (long) map.get(PENDING); - + idle = (Long) map.get(IDLE); + pending = (Long) map.get(PENDING); + inactive = (Long) map.get(INACTIVE); } public String getName() { @@ -44,6 +46,14 @@ public long getPending() { } /** + * Since Redis 7.2. + */ + public Long getInactive() { + return inactive; + } + + /** + * All data. * @return Generic map containing all key-value pairs returned by the server */ public Map getConsumerInfo() { diff --git a/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java b/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java index e42c55a4f7..5167cd1fa7 100644 --- a/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java +++ b/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java @@ -18,6 +18,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicReference; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; import org.junit.Test; import redis.clients.jedis.BuilderFactory; @@ -846,7 +848,8 @@ public void xinfo() throws InterruptedException { // Using getters assertEquals(MY_CONSUMER, consumersInfo.get(0).getName()); assertEquals(0L, consumersInfo.get(0).getPending()); - assertTrue(consumersInfo.get(0).getIdle() > 0); + MatcherAssert.assertThat(consumersInfo.get(0).getIdle(), Matchers.greaterThanOrEqualTo(0L)); + MatcherAssert.assertThat(consumersInfo.get(0).getInactive(), Matchers.any(Long.class)); // test with more groups and consumers jedis.xgroupCreate(STREAM_NAME, G2, StreamEntryID.LAST_ENTRY, false);