Skip to content

Commit

Permalink
fix: sorted set remove request (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
eaddingtonwhite authored and cprice404 committed Mar 14, 2023
1 parent 4985173 commit 8370836
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 9 additions & 0 deletions momento/sorted_set_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,18 @@ func (r *SortedSetFetchRequest) initGrpcRequest(scsDataClient) error {
}

switch numResults := r.NumberOfResults.(type) {
case *FetchAllElements:
grpcReq.NumResults = &pb.XSortedSetFetchRequest_All{}
case FetchAllElements:
grpcReq.NumResults = &pb.XSortedSetFetchRequest_All{}
case nil:
grpcReq.NumResults = &pb.XSortedSetFetchRequest_All{}
case *FetchLimitedElements:
grpcReq.NumResults = &pb.XSortedSetFetchRequest_Limit{
Limit: &pb.XSortedSetFetchRequest_XLimit{
Limit: numResults.Limit,
},
}
case FetchLimitedElements:
grpcReq.NumResults = &pb.XSortedSetFetchRequest_Limit{
Limit: &pb.XSortedSetFetchRequest_XLimit{
Expand Down
12 changes: 10 additions & 2 deletions momento/sorted_set_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type RemoveAllElements struct{}
func (RemoveAllElements) isSortedSetRemoveNumElement() {}

type RemoveSomeElements struct {
elementsToRemove []Bytes
Elements []Bytes
}

func (RemoveSomeElements) isSortedSetRemoveNumElement() {}
Expand All @@ -63,12 +63,20 @@ func (r *SortedSetRemoveRequest) initGrpcRequest(scsDataClient) error {
}

switch toRemove := r.ElementsToRemove.(type) {
case RemoveAllElements:
grpcReq.RemoveElements = &pb.XSortedSetRemoveRequest_All{}
case *RemoveAllElements:
grpcReq.RemoveElements = &pb.XSortedSetRemoveRequest_All{}
case RemoveSomeElements:
grpcReq.RemoveElements = &pb.XSortedSetRemoveRequest_Some{
Some: &pb.XSortedSetRemoveRequest_XSome{
ElementName: momentoBytesListToPrimitiveByteList(toRemove.Elements),
},
}
case *RemoveSomeElements:
grpcReq.RemoveElements = &pb.XSortedSetRemoveRequest_Some{
Some: &pb.XSortedSetRemoveRequest_XSome{
ElementName: momentoBytesListToPrimitiveByteList(toRemove.elementsToRemove),
ElementName: momentoBytesListToPrimitiveByteList(toRemove.Elements),
},
}
default:
Expand Down

0 comments on commit 8370836

Please sign in to comment.