Skip to content

Commit

Permalink
refactor: rename SortedSetRemove to SortedSetRemoveElements (#259)
Browse files Browse the repository at this point in the history
Also renames request, response, and interface as appropriate.
  • Loading branch information
malandis authored Mar 10, 2023
1 parent 5569bee commit 4bd7ef4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions momento/cache_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type CacheClient interface {
SortedSetFetch(ctx context.Context, r *SortedSetFetchRequest) (responses.SortedSetFetchResponse, error)
SortedSetPut(ctx context.Context, r *SortedSetPutRequest) (responses.SortedSetPutResponse, error)
SortedSetGetScores(ctx context.Context, r *SortedSetGetScoresRequest) (responses.SortedSetGetScoresResponse, error)
SortedSetRemove(ctx context.Context, r *SortedSetRemoveRequest) (responses.SortedSetRemoveResponse, error)
SortedSetRemoveElements(ctx context.Context, r *SortedSetRemoveElementsRequest) (responses.SortedSetRemoveElementsResponse, error)
SortedSetGetRank(ctx context.Context, r *SortedSetGetRankRequest) (responses.SortedSetGetRankResponse, error)
SortedSetIncrementScore(ctx context.Context, r *SortedSetIncrementScoreRequest) (responses.SortedSetIncrementScoreResponse, error)

Expand Down Expand Up @@ -226,7 +226,7 @@ func (c defaultScsClient) SortedSetGetScores(ctx context.Context, r *SortedSetGe
return r.response, nil
}

func (c defaultScsClient) SortedSetRemove(ctx context.Context, r *SortedSetRemoveRequest) (responses.SortedSetRemoveResponse, error) {
func (c defaultScsClient) SortedSetRemoveElements(ctx context.Context, r *SortedSetRemoveElementsRequest) (responses.SortedSetRemoveElementsResponse, error) {
if err := c.dataClient.makeRequest(ctx, r); err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import (
pb "github.com/momentohq/client-sdk-go/internal/protos"
)

type SortedSetRemoveRequest struct {
type SortedSetRemoveElementsRequest struct {
CacheName string
SetName string
Values []Value

grpcRequest *pb.XSortedSetRemoveRequest
grpcResponse *pb.XSortedSetRemoveResponse
response responses.SortedSetRemoveResponse
response responses.SortedSetRemoveElementsResponse
}

func (r *SortedSetRemoveRequest) cacheName() string { return r.CacheName }
func (r *SortedSetRemoveElementsRequest) cacheName() string { return r.CacheName }

func (r *SortedSetRemoveRequest) requestName() string { return "Sorted set remove" }
func (r *SortedSetRemoveElementsRequest) requestName() string { return "Sorted set remove" }

func (r *SortedSetRemoveRequest) values() []Value { return r.Values }
func (r *SortedSetRemoveElementsRequest) values() []Value { return r.Values }

func (r *SortedSetRemoveRequest) initGrpcRequest(scsDataClient) error {
func (r *SortedSetRemoveElementsRequest) initGrpcRequest(scsDataClient) error {
var err error

if _, err = prepareName(r.SetName, "Set name"); err != nil {
Expand All @@ -49,7 +49,7 @@ func (r *SortedSetRemoveRequest) initGrpcRequest(scsDataClient) error {
return nil
}

func (r *SortedSetRemoveRequest) makeGrpcRequest(metadata context.Context, client scsDataClient) (grpcResponse, error) {
func (r *SortedSetRemoveElementsRequest) makeGrpcRequest(metadata context.Context, client scsDataClient) (grpcResponse, error) {
resp, err := client.grpcClient.SortedSetRemove(metadata, r.grpcRequest)
if err != nil {
return nil, err
Expand All @@ -60,7 +60,7 @@ func (r *SortedSetRemoveRequest) makeGrpcRequest(metadata context.Context, clien
return resp, nil
}

func (r *SortedSetRemoveRequest) interpretGrpcResponse() error {
func (r *SortedSetRemoveElementsRequest) interpretGrpcResponse() error {
r.response = &responses.SortedSetRemoveSuccess{}
return nil
}
18 changes: 9 additions & 9 deletions momento/sorted_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var _ = Describe("SortedSet", func() {
).Error().To(HaveMomentoErrorCode(expectedError))

Expect(
client.SortedSetRemove(ctx, &SortedSetRemoveRequest{
client.SortedSetRemoveElements(ctx, &SortedSetRemoveElementsRequest{
CacheName: cacheName, SetName: collectionName, Values: values,
}),
).Error().To(HaveMomentoErrorCode(expectedError))
Expand Down Expand Up @@ -702,9 +702,9 @@ var _ = Describe("SortedSet", func() {
Describe(`SortedSetRemove`, func() {
It(`Succeeds when the element does not exist`, func() {
Expect(
sharedContext.Client.SortedSetRemove(
sharedContext.Client.SortedSetRemoveElements(
sharedContext.Ctx,
&SortedSetRemoveRequest{
&SortedSetRemoveElementsRequest{
CacheName: sharedContext.CacheName,
SetName: sharedContext.CollectionName,
Values: []Value{String("dne")},
Expand All @@ -723,9 +723,9 @@ var _ = Describe("SortedSet", func() {
)

Expect(
sharedContext.Client.SortedSetRemove(
sharedContext.Client.SortedSetRemoveElements(
sharedContext.Ctx,
&SortedSetRemoveRequest{
&SortedSetRemoveElementsRequest{
CacheName: sharedContext.CacheName,
SetName: sharedContext.CollectionName,
Values: []Value{
Expand Down Expand Up @@ -753,9 +753,9 @@ var _ = Describe("SortedSet", func() {

It("returns an error when elements are nil", func() {
Expect(
sharedContext.Client.SortedSetRemove(
sharedContext.Client.SortedSetRemoveElements(
sharedContext.Ctx,
&SortedSetRemoveRequest{
&SortedSetRemoveElementsRequest{
CacheName: sharedContext.CacheName,
SetName: sharedContext.CollectionName,
Values: nil,
Expand All @@ -764,9 +764,9 @@ var _ = Describe("SortedSet", func() {
).Error().To(HaveMomentoErrorCode(InvalidArgumentError))

Expect(
sharedContext.Client.SortedSetRemove(
sharedContext.Client.SortedSetRemoveElements(
sharedContext.Ctx,
&SortedSetRemoveRequest{
&SortedSetRemoveElementsRequest{
CacheName: sharedContext.CacheName,
SetName: sharedContext.CollectionName,
Values: []Value{nil, String("aValue"), nil},
Expand Down
2 changes: 1 addition & 1 deletion responses/sorted_set_remove.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package responses

type SortedSetRemoveResponse interface {
type SortedSetRemoveElementsResponse interface {
isSortedSetRemoveResponse()
}

Expand Down

0 comments on commit 4bd7ef4

Please sign in to comment.