1
- use crate :: { RedisErr , RedisResult , TimestampFormat as TsFmt , MSG , ZERO } ;
1
+ use crate :: { MessageField as MsgF , RedisErr , RedisResult , TimestampFormat as TsFmt , ZERO } ;
2
2
use redis:: Value ;
3
3
use sea_streamer_types:: {
4
4
MessageHeader , SeqNo , ShardId , SharedMessage , StreamErr , StreamKey , Timestamp ,
@@ -66,6 +66,7 @@ pub(crate) fn get_message_id(header: &MessageHeader) -> MessageId {
66
66
67
67
#[ inline]
68
68
pub ( crate ) fn from_seq_no ( seq_no : SeqNo ) -> MessageId {
69
+ #[ allow( clippy:: unnecessary_cast) ]
69
70
( ( seq_no >> 16 ) as u64 , ( seq_no & 0xFFFF ) as u16 )
70
71
}
71
72
@@ -85,7 +86,7 @@ impl RedisMessageId for RedisMessage {
85
86
// LOL such nesting. This is still undesirable, as there are 5 layers of nested Vec. But at least we don't have to copy the bytes again.
86
87
impl StreamReadReply {
87
88
/// Like [`redis::FromRedisValue`], but taking ownership instead of copying.
88
- pub ( crate ) fn from_redis_value ( value : Value , ts_fmt : TsFmt ) -> RedisResult < Self > {
89
+ pub ( crate ) fn from_redis_value ( value : Value , ts_fmt : TsFmt , msg : MsgF ) -> RedisResult < Self > {
89
90
let mut messages = Vec :: new ( ) ;
90
91
91
92
if let Value :: Bulk ( values) = value {
@@ -113,7 +114,7 @@ impl StreamReadReply {
113
114
} ;
114
115
let stream_key = StreamKey :: new ( stream_key) ?;
115
116
if let Value :: Bulk ( values) = value_1 {
116
- parse_messages ( values, stream_key, shard, & mut messages, ts_fmt) ?;
117
+ parse_messages ( values, stream_key, shard, & mut messages, ts_fmt, msg ) ?;
117
118
}
118
119
}
119
120
}
@@ -129,6 +130,7 @@ impl AutoClaimReply {
129
130
stream_key : StreamKey ,
130
131
shard : ShardId ,
131
132
ts_fmt : TsFmt ,
133
+ msg : MsgF ,
132
134
) -> RedisResult < Self > {
133
135
let mut messages = Vec :: new ( ) ;
134
136
if let Value :: Bulk ( values) = value {
@@ -139,7 +141,7 @@ impl AutoClaimReply {
139
141
_ = values. next ( ) . unwrap ( ) ;
140
142
let value = values. next ( ) . unwrap ( ) ;
141
143
if let Value :: Bulk ( values) = value {
142
- parse_messages ( values, stream_key, shard, & mut messages, ts_fmt) ?;
144
+ parse_messages ( values, stream_key, shard, & mut messages, ts_fmt, msg ) ?;
143
145
} else {
144
146
return Err ( err ( value) ) ;
145
147
}
@@ -154,6 +156,7 @@ fn parse_messages(
154
156
shard : ShardId ,
155
157
messages : & mut Vec < RedisMessage > ,
156
158
ts_fmt : TsFmt ,
159
+ msg : MsgF ,
157
160
) -> RedisResult < ( ) > {
158
161
for value in values {
159
162
if let Value :: Bulk ( values) = value {
@@ -173,7 +176,7 @@ fn parse_messages(
173
176
let field = values. next ( ) . unwrap ( ) ;
174
177
let field = string_from_redis_value ( field) ?;
175
178
let value = values. next ( ) . unwrap ( ) ;
176
- if field == MSG {
179
+ if field == msg . 0 {
177
180
let bytes = bytes_from_redis_value ( value) ?;
178
181
let length = bytes. len ( ) ;
179
182
messages. push ( RedisMessage :: new (
0 commit comments