feat(java): add stream commands to Jedis compatibility layer#5289
feat(java): add stream commands to Jedis compatibility layer#5289prashanna-frsh wants to merge 8 commits intovalkey-io:mainfrom
Conversation
|
Hi @prashanna-frsh, it looks like your commits are not verified. We have a policy that all commits needs to have signing and signoff. We can help review your PR after these are being taken care of. |
6e5157f to
e1aecee
Compare
added it |
| if (arr == null || arr.length < 4) { | ||
| return new StreamPendingSummary( | ||
| 0L, new StreamEntryID("0-0"), new StreamEntryID("0-0"), Collections.emptyMap()); | ||
| } | ||
| long total = | ||
| arr[0] instanceof Long ? (Long) arr[0] : Long.parseLong(String.valueOf(arr[0])); | ||
| String minIdStr = String.valueOf(arr[1]); | ||
| String maxIdStr = String.valueOf(arr[2]); | ||
| if (minIdStr == null || minIdStr.isEmpty() || "null".equals(minIdStr)) { | ||
| minIdStr = "0-0"; | ||
| } | ||
| if (maxIdStr == null || maxIdStr.isEmpty() || "null".equals(maxIdStr)) { | ||
| maxIdStr = "0-0"; | ||
| } |
There was a problem hiding this comment.
Should these statements return null instead of "0-0" when no pending messages to stay consistent with Jedis?
See Jedis implementation for StreamEntryID:
https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/BuilderFactory.java#L1940-L1941
https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/BuilderFactory.java#L1291-L1293
There was a problem hiding this comment.
addressed it
| - ✅ List operations (LPUSH, RPUSH, LPOP, RPOP) | ||
| - ⚠️ Set operations (SADD, SREM, SMEMBERS) - **Available via `sendCommand()` only** | ||
| - ⚠️ Sorted set operations (ZADD, ZREM, ZRANGE) - **Available via `sendCommand()` only** | ||
| - ✅ Stream operations (XADD, XLEN, XDEL, XRANGE, XREVRANGE, XREAD, XTRIM, XGROUP CREATE/DESTROY/SETID, XREADGROUP, XACK, XPENDING, XCLAIM, XAUTOCLAIM, XINFO STREAM/GROUPS/CONSUMERS) |
There was a problem hiding this comment.
Could also mention stream XSETID is not supported (although XGROUP SETID is supported). Perhaps a note after this list of commands.
Also, should we add a Stream Commands section to the README.md, similar to how #5305 added a section for the Scripting Commands?
There was a problem hiding this comment.
agree to this,
As I've few other PR's for different commands, post merge i've planned to write extensive docs for jedis-compatibility layer which will be in separate PR.
| * @param hash field-value map | ||
| * @return generated entry ID | ||
| */ | ||
| public StreamEntryID xadd(String key, Map<String, String> hash) { |
There was a problem hiding this comment.
We're missing the XAddParams parameter. Also this function looks like it's supposed to return byte[].
There was a problem hiding this comment.
addressed it
| } | ||
|
|
||
| /** Returns the number of entries in the stream. Uses GLIDE xlen. */ | ||
| public long xlen(String key) { |
There was a problem hiding this comment.
Missing the binary variant of this
There was a problem hiding this comment.
added the missing binary methods
Signed-off-by: prashanna-frsh <prashanna.rajendran@freshworks.com>
Signed-off-by: prashanna-frsh <prashanna.rajendran@freshworks.com>
Signed-off-by: prashanna-frsh <prashanna.rajendran@freshworks.com>
Signed-off-by: prashanna-frsh <prashanna.rajendran@freshworks.com>
Signed-off-by: prashanna-frsh <prashanna.rajendran@freshworks.com>
Signed-off-by: prashanna-frsh <prashanna.rajendran@freshworks.com>
acddfa5 to
a6dcd63
Compare
…x errors Signed-off-by: prashanna-frsh <prashanna.rajendran@freshworks.com> Co-authored-by: Cursor <cursoragent@cursor.com>
7f4211c to
31f804d
Compare
Summary
Add stream command support to the Jedis compatibility layer using the GLIDE Java type-safe API. All stream methods in
Jedis.javadelegate toGlideClient(nocustomCommand()). Includes migration guide updates, integration and unit tests, XPENDING null-id handling, and Javadoc fixes for the javadoc task.Issue link
This Pull Request is linked to issue (URL): [https://github.com//issues/5288]
Features / Behaviour Changes
StreamEntryID,List<StreamEntry>,Map<String, List<StreamEntry>>,StreamPendingSummary,List<StreamPendingEntry>,StreamInfo,List<StreamGroupInfo>,List<StreamConsumerInfo>as appropriate.Implementation
Jedis.java: New stream section with helperstoStreamEntryList()andtoStreamReadResponse()to map GLIDEMap<String, String[][]>to JedisList<StreamEntry>andMap<String, List<StreamEntry>>. Range bounds"-"/"+"map toStreamRange.InfRangeBound.MIN/MAX; other IDs useStreamRange.IdBound.of(id). Options use GLIDEStreamAddOptions,StreamReadOptions,StreamReadGroupOptions,StreamTrimOptions,StreamGroupOptions,StreamPendingOptions,StreamClaimOptions."0-0"before constructingStreamEntryIDto avoidNumberFormatException.xinfoStream()returns rawMap<String, Object>;xinfoStreamAsInfo()buildsStreamInfowithlast-generated-idand first/last entry conversion.xinfoGroups/xinfoConsumersconvert raw maps toStreamGroupInfo/StreamConsumerInfo(includinglast-delivered-id→StreamEntryID).->with " to " andList<StreamEntry>with "List of StreamEntry" in comments to fix javadoc "bad use of '>'" and unknown tag errors.Limitations
customCommand().Testing
JedisMethodsTest.testStreamMethodSignaturesExistandtestStreamMethodReturnTypesverify stream method presence and return types. Run:./gradlew :jedis-compatibility:test --tests 'redis.clients.jedis.JedisMethodsTest.testStream*'JedisTest.stream_*(10 tests: xadd/xlen/xdel, xrange/xrevrange, xread, xtrim, xgroup create/destroy, xgroup setid/createconsumer/delconsumer, xreadgroup/xack, xpending, xinfo stream/groups, xinfo consumers). Run:./gradlew :integTest:test --tests 'compatibility.jedis.JedisTest.stream_*'stream_xgroup_create_destroyno longer calls XGROUP CREATE twice (removed second create that caused BUSYGROUP).stream_xpendingpasses after normalizing null min/max id to"0-0".Checklist
Before submitting the PR make sure the following are checked:
make *-linttargets) and Prettier has been run (make prettier-fix).