-   Notifications  
You must be signed in to change notification settings  - Fork 2.5k
 
Description
Currently, there are few commands which takes varargs(args ...interface{}) for additional arguments. Examples include BitFieldRO, SAdd.
 We handle the args in several ways(non exhaustive list) -
- Have validation on the args array - BitFieldRO
 - Let Redis handle it - no args(members) in SAdd will make redis throw an error
 
These commands make it harder for users to reason on what is acceptable and what is not. Users have to refer to Redis documentation to know what fields need to be passed and type of them.
I want to propose either updating these commands to take types args or creating new commands(to avoid breaking client usages on library upgrade).
For commands of type 1, below is my proposal -
func (c cmdable) BitFieldRO(ctx context.Context, key string, values []EncodingWithOffest) *IntSliceCmd { ... } type EncodingWithOffset struct { Encoding Encoding // we can use string or enums Offset int64 }For commands of type 2, I would prefer if the commands can enforce obvious error scenarios such as no args passed in SAdd like below -
func (c cmdable) SAdd(ctx context.Context, key string, member interface{}, additionalMembers ...interface{}) *IntCmd { ... }This is not a concrete proposal of how the type safe APIs will look like. I would like to discuss with you all on what's the best way to model them.
 I am happy to contribute code if go-redis team is okay with this feature request.
 Thanks!