File tree Expand file tree Collapse file tree 3 files changed +37
-9
lines changed Expand file tree Collapse file tree 3 files changed +37
-9
lines changed Original file line number Diff line number Diff line change @@ -308,14 +308,24 @@ def parse_xautoclaim(response, **options):
308
308
return parse_stream_list (response [1 ])
309
309
310
310
311
- def parse_xinfo_stream (response ):
311
+ def parse_xinfo_stream (response , ** options ):
312
312
data = pairs_to_dict (response , decode_keys = True )
313
- first = data ['first-entry' ]
314
- if first is not None :
315
- data ['first-entry' ] = (first [0 ], pairs_to_dict (first [1 ]))
316
- last = data ['last-entry' ]
317
- if last is not None :
318
- data ['last-entry' ] = (last [0 ], pairs_to_dict (last [1 ]))
313
+ if not options .get ('full' , False ):
314
+ first = data ['first-entry' ]
315
+ if first is not None :
316
+ data ['first-entry' ] = (first [0 ], pairs_to_dict (first [1 ]))
317
+ last = data ['last-entry' ]
318
+ if last is not None :
319
+ data ['last-entry' ] = (last [0 ], pairs_to_dict (last [1 ]))
320
+ else :
321
+ data ['entries' ] = {
322
+ _id : pairs_to_dict (entry )
323
+ for _id , entry in data ['entries' ]
324
+ }
325
+ data ['groups' ] = [
326
+ pairs_to_dict (group , decode_keys = True )
327
+ for group in data ['groups' ]
328
+ ]
319
329
return data
320
330
321
331
Original file line number Diff line number Diff line change @@ -2050,12 +2050,18 @@ def xinfo_groups(self, name):
2050
2050
"""
2051
2051
return self .execute_command ('XINFO GROUPS' , name )
2052
2052
2053
- def xinfo_stream (self , name ):
2053
+ def xinfo_stream (self , name , full = False ):
2054
2054
"""
2055
2055
Returns general information about the stream.
2056
2056
name: name of the stream.
2057
+ full: optional boolean, false by default. Return full summary
2057
2058
"""
2058
- return self .execute_command ('XINFO STREAM' , name )
2059
+ pieces = [name ]
2060
+ options = {}
2061
+ if full :
2062
+ pieces .append (b'FULL' )
2063
+ options = {'full' : full }
2064
+ return self .execute_command ('XINFO STREAM' , * pieces , ** options )
2059
2065
2060
2066
def xlen (self , name ):
2061
2067
"""
Original file line number Diff line number Diff line change @@ -3156,6 +3156,18 @@ def test_xinfo_stream(self, r):
3156
3156
assert info ['first-entry' ] == get_stream_message (r , stream , m1 )
3157
3157
assert info ['last-entry' ] == get_stream_message (r , stream , m2 )
3158
3158
3159
+ @skip_if_server_version_lt ('6.0.0' )
3160
+ def test_xinfo_stream_full (self , r ):
3161
+ stream = 'stream'
3162
+ group = 'group'
3163
+ m1 = r .xadd (stream , {'foo' : 'bar' })
3164
+ r .xgroup_create (stream , group , 0 )
3165
+ info = r .xinfo_stream (stream , full = True )
3166
+
3167
+ assert info ['length' ] == 1
3168
+ assert m1 in info ['entries' ]
3169
+ assert len (info ['groups' ]) == 1
3170
+
3159
3171
@skip_if_server_version_lt ('5.0.0' )
3160
3172
def test_xlen (self , r ):
3161
3173
stream = 'stream'
You can’t perform that action at this time.
0 commit comments