Skip to content
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

feat: Change back to returning responses as pointers #121

Merged
merged 5 commits into from
Feb 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat!: Change SortedSetFEtch to return a pointer.
Demonstration of how to change from returning response values to pointers.
schwern committed Feb 14, 2023

Unverified

No user is associated with the committer email.
commit 18ab66e3889c21cb173a220efadce2f1e5159d26
4 changes: 2 additions & 2 deletions examples/sortedset-example/main.go
Original file line number Diff line number Diff line change
@@ -100,8 +100,8 @@ func setupCache(client momento.ScsClient, ctx context.Context) {
}
}

func displayElements(setName string, resp momento.SortedSetFetchResponse) {
switch r := resp.(type) {
func displayElements(setName string, resp *momento.SortedSetFetchResponse) {
switch r := (*resp).(type) {
case momento.SortedSetFetchHit:
for _, e := range r.Elements {
fmt.Printf("setName: %s, elementName: %s, score: %f\n", setName, e.Name, e.Score)
2 changes: 1 addition & 1 deletion momento/simple_cache_client.go
Original file line number Diff line number Diff line change
@@ -162,7 +162,7 @@ func (c ScsClient) TopicPublish(ctx context.Context, request *TopicPublishReques
return TopicPublishSuccess{}, err
}

func (c ScsClient) SortedSetFetch(ctx context.Context, r *SortedSetFetchRequest) (SortedSetFetchResponse, error) {
func (c ScsClient) SortedSetFetch(ctx context.Context, r *SortedSetFetchRequest) (*SortedSetFetchResponse, error) {
if err := c.dataClient.makeRequest(ctx, r); err != nil {
return nil, err
}
4 changes: 2 additions & 2 deletions momento/sorted_set_fetch.go
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ type SortedSetFetchRequest struct {

grpcRequest *pb.XSortedSetFetchRequest
grpcResponse *pb.XSortedSetFetchResponse
response SortedSetFetchResponse
response *SortedSetFetchResponse
}

func (r SortedSetFetchRequest) cacheName() string { return r.CacheName }
@@ -125,7 +125,7 @@ func (r *SortedSetFetchRequest) interpretGrpcResponse() error {
return errUnexpectedGrpcResponse
}

r.response = resp
r.response = &resp

return nil
}