-
Notifications
You must be signed in to change notification settings - Fork 68
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
Go: Implement Bitfield and Bitfield ReadOnly commands #2999
base: main
Are you sure you want to change the base?
Go: Implement Bitfield and Bitfield ReadOnly commands #2999
Conversation
Signed-off-by: Niharika Bhavaraju <[email protected]>
return &BitFieldOptions{} | ||
} | ||
|
||
// AddGet adds a GET subcommand |
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.
Don't we need docs for parameters?
return opts | ||
} | ||
|
||
func (opts *BitFieldOptions) ToArgs() []string { |
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.
Probably return a tuple to align with others, even when error
is always nil
for now
func (opts *BitFieldOptions) ToArgs() []string { | |
func (opts *BitFieldOptions) ToArgs() ([]string, error) { |
// fmt.Println(result) // Output: [7 13] | ||
// | ||
// [valkey.io]: https://valkey.io/commands/bitfield/ | ||
func (client *baseClient) BitField(key string, options *options.BitFieldOptions) ([]int64, error) { |
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.
With *options
(pointer) a user can pass nil
, but API is not designed to support this I think.
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.
Alternative variant is
func (client *baseClient) BitField(key string, options *options.BitFieldOptions) ([]int64, error) { | |
func (client *baseClient) BitField(key string, subcommands []BitFieldSubcommand) ([]int64, error) { |
where
type BitFieldSubcommand interface {
ToArgs() ([]string, error)
}
And you can share implementations for BitField
and BitFieldRO
I did similar thing for ZRange
@@ -321,6 +321,29 @@ func handleIntArrayResponse(response *C.struct_CommandResponse) ([]int64, error) | |||
return slice, nil | |||
} | |||
|
|||
func handleIntOrNilArrayResponse(response *C.struct_CommandResponse) ([]int64, error) { |
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.
We already have https://github.com/niharikabhavaraju/valkey-glide/blob/34bd8722ad34a0ba7b37407a5752c8851feee9ce/go/api/response_handlers.go#L305
Or you want nil
lable ints there?
func handleIntOrNilArrayResponse(response *C.struct_CommandResponse) ([]int64, error) { | |
func handleIntOrNilArrayResponse(response *C.struct_CommandResponse) ([]Result[int64], error) { |
Go: Implement Bitfield and Bitfield ReadOnly commands