Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update XINFO CONSUMERS reply #3422

Merged
merged 2 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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