Skip to content

Commit

Permalink
Update XINFO CONSUMERS reply (#3422)
Browse files Browse the repository at this point in the history
with inactive field.
  • Loading branch information
sazzad16 authored May 18, 2023
1 parent 9803f89 commit c0554f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/main/java/redis/clients/jedis/resps/StreamConsumersInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Object> consumerInfo;

/**
Expand All @@ -26,9 +28,9 @@ public StreamConsumersInfo(Map<String, Object> 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() {
Expand All @@ -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<String, Object> getConsumerInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c0554f6

Please sign in to comment.