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

Inconsistency in response type handling for GetBatch and SetBatch API methods #445

Open
Takashicc opened this issue Jul 5, 2024 · 0 comments

Comments

@Takashicc
Copy link

When handling the results after calling (momento.CacheClient) GetBatch, I attempted to handle it as follows:

result, err := momentoClient.GetBatch(ctx, &momento.GetBatchRequest{
    CacheName: cacheName,
    Keys:      keys,
})
if err != nil {
    return nil, err
}

switch val := result.(type) {
case *responses.GetBatchSuccess:
    return val.ValueMap(), nil
default:
    return nil, fmt.Errorf("unexpected response type: %T", val)
}

However, since the type returned by GetBatch is not a pointer, it seems that I need to use case responses.GetBatchSuccess instead. This behavior differs from other APIs where the handling is done with pointers.
I have noticed the same behavior with SetBatch as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant