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

fix: add message wrapper to errors and improve resource exhausted error message by using metadata #551

Merged
merged 7 commits into from
Nov 4, 2024

Conversation

anitarua
Copy link
Contributor

@anitarua anitarua commented Oct 29, 2024

Closes https://github.com/momentohq/dev-eco-issue-tracker/issues/1038

  • When a RESOURCE_EXHAUSTED error is received, we now parse the err metadata in order to report the cause in the message wrapper. If the metadata is not available, we try to use string matching on the error details.
  • Adds the missing message wrapper component for consistency with the other SDKs.
  • Adds ability to get header and trailer metadata (as per the docs) from each RPC call across the various clients. Otherwise, metadata is not available for parsing.
  • Deprecates AlreadyExistsError in favor of CacheAlreadyExistsError and StoreAlreadyExistsError for consistency with the other SDKs.

@@ -30,7 +31,7 @@ func errUnexpectedGrpcResponse(r requester, grpcResp grpcResponse) momentoerrors
type requester interface {
hasCacheName
initGrpcRequest(client scsDataClient) error
makeGrpcRequest(metadata context.Context, client scsDataClient) (grpcResponse, error)
makeGrpcRequest(requestMetadata context.Context, client scsDataClient) (grpcResponse, []metadata.MD, error)
Copy link
Contributor Author

@anitarua anitarua Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to update this signature to be able to get the response metadata in the cache data client.
a lot of the changes are to make the requests conform to this change.

@anitarua anitarua marked this pull request as ready for review October 29, 2024 22:00
@anitarua anitarua requested a review from a team October 29, 2024 22:00
Copy link
Contributor

@malandis malandis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a comprehensive change.

Suggestions for improvement:

  • Centralize all static strings to one place
  • Extract any complicated error logic to a function instead of directly in a switch

This way we can write unit tests for various more complicated things, and maintain uniformity over the messages.

@anitarua anitarua requested a review from malandis October 31, 2024 21:06
Copy link
Contributor

@malandis malandis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last question otherwise good to go.

@anitarua anitarua merged commit 19bd021 into main Nov 4, 2024
6 checks passed
@anitarua anitarua deleted the resource-exhausted branch November 4, 2024 23:21
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

Successfully merging this pull request may close these issues.

None yet

2 participants