-
Notifications
You must be signed in to change notification settings - Fork 228
Feat rueidiscompat redisearch #676
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
Conversation
…INDEXEMPTY, INDEXMISSING options
…rchRESP3 and compat-redisearch
9e209e6 to
9320786
Compare
message.go
Outdated
| func (r RedisResult) IsMap() bool { | ||
| return r.val.IsMap() | ||
| } | ||
|
|
||
| // IsArray delegates to RedisMessage.IsArray | ||
| func (r RedisResult) IsArray() bool { | ||
| return r.val.IsArray() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| func (r RedisResult) IsMap() bool { | |
| return r.val.IsMap() | |
| } | |
| // IsArray delegates to RedisMessage.IsArray | |
| func (r RedisResult) IsArray() bool { | |
| return r.val.IsArray() | |
| } | |
| func (r RedisResult) isMap() bool { | |
| return r.val.IsMap() | |
| } | |
| // IsArray delegates to RedisMessage.IsArray | |
| func (r RedisResult) isArray() bool { | |
| return r.val.IsArray() | |
| } |
Can we make these 2 methods private first? I am concerned about making these direct delegations to r.val as public APIs. I think we should at least ask users to check the r.err first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if we make IsMap private, functions in command.go can not access it,
I think we could check if any error exists, then delegate to r.val.IsMap.
func (r RedisResult) IsMap() bool {
if r.err != nil {
panic(fmt.Errorf("RedisResult has error: %w, please check the error before calling RedisResult.IsMap", r.err))
}
return r.val.IsMap()
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPDATE: I'll use res.ToMessage() to get underlying message first, then do the IsMap, IsArray check.
rueidiscompat/util.go
Outdated
| func Sleep(ctx context.Context, dur time.Duration) error { | ||
| t := time.NewTimer(dur) | ||
| defer t.Stop() | ||
|
|
||
| select { | ||
| case <-t.C: | ||
| return nil | ||
| case <-ctx.Done(): | ||
| return ctx.Err() | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove unused functions in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
message.go
Outdated
| err = r.err | ||
| } else { | ||
| v, err = r.val.ToMap() | ||
| v, err = r.val.AsMap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this change? I think we already have an AsMap delegation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is accidentally committed, I've reverted it.
afb8492 to
ec1b389
Compare
Changes and cautions:
compat-redisearchservice for testingRediSearchwithRESP2INDEXEMPTY,INDEXMISSING,WITHCOUNT,ADDSCORESGEOSHAPEWITHCOUNTSUMMARIZEoptionWITHCOUNT