From c0554f6edd6f52242cc7cb1682c0cf3de0fc3a7d Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Thu, 18 May 2023 17:25:12 +0600 Subject: [PATCH] Update XINFO CONSUMERS reply (#3422) with inactive field. --- .../clients/jedis/resps/StreamConsumersInfo.java | 16 +++++++++++++--- .../commands/jedis/StreamsCommandsTest.java | 3 ++- 2 files changed, 15 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 75e4aef84e..16618c5288 100644 --- a/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java +++ b/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java @@ -848,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);