-
Notifications
You must be signed in to change notification settings - Fork 112
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
errors: pager API errors refactor #1160
Conversation
See the following report for details: cargo semver-checks output
|
c4b17fe
to
3cfdcc7
Compare
3cfdcc7
to
dc72120
Compare
dc72120
to
3047435
Compare
/// Failed to deserialize result metadata associated with next page response. | ||
#[error("Failed to deserialize result metadata associated with next page response: {0}")] | ||
ResultMetadataParseError(#[from] ResultMetadataAndRowsCountParseError), | ||
// TODO: This should also include a variant representing an error that occurred during | ||
// query that fetches the next page. However, as of now, it would require that we include QueryError here. | ||
// This would introduce a cyclic dependency: QueryError -> NextRowError -> NextPageError -> QueryError. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit: "iterator: narrow error type of internal items "
❓ You removed this comment, and included "RequestFailure". This does not introduce a cycle because you used "RequestError" instead of "QueryError", right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.
// FIXME 2: The specific error we expect here should appear in QueryError::NextRowError. Currently | ||
// leaving match against both variants. This will be fixed, once `MetadataError` is further adjusted | ||
// in a follow-up PR. The goal is to return MetadataError from all functions related to metadata fetch. | ||
Err(QueryError::DbError(DbError::Invalid, _)) | ||
| Err(QueryError::NextRowError(NextRowError::NextPageError( | ||
NextPageError::RequestFailure(RequestError::LastAttemptError( | ||
RequestAttemptError::DbError(DbError::Invalid, _), | ||
)), | ||
))) => Ok(HashMap::new()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Why can't you just move this commit before the previous one? Then all the commits would compile and pass tests, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I'll do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, but I lied in the PR cover letter. I mentioned that penultimate commit breaks things. I moved the commit with the fix, before iterator: narrow error type of internal items
.
I marked `PartitionKeyError` as non_exhaustive. Narrowed the return type of remaining funtions that returned `QueryError` to `PartitionKeyError`. Added an explicit conversion function PartitionKeyError -> QueryError.
This change is required for the tests to pass after next commit. The next commit causes the DbError in topology code to be placed under QueryError::NextRowError. Without this change, tests fail, because we propagate the error for Cassandra clusters, instead of ignoring it.
Narrowed the error types in multiple places in internal API of iterator module. Now the error type we manipulate on mainly is `NextPageError` (instead of `QueryError`). I did not change the return type of public methods yet. I want to do it in a separate commit.
3047435
to
04c7eec
Compare
v1.1:
|
Ref: #519
Motivation
There are three main objectives:
Purge pager.rs module of QueryError
It's yet another module where usage of
QueryError
was abused. It's taken care of in this PRNarrow return error type of
[poll_]next()
methods on iterators/streamsThey now return a self-contained
NextRow
error. It's independent ofQueryError
.Step forward narrowing error type of metadata related functions
Currently all top-level metadata related functions/methods (e.g.
Session::refresh_metadata
) returnQueryError
. This is because low-level methods useQueryPager
API under the hood. Before this PR, the pager API would returnQueryError
. In the follow-up PR we will continue on purging the metadata methods ofQueryError
. It will be replaced with an error type designated for these operations - namelyMetadataError
.Pre-review checklist
[ ] I added relevant tests for new features and bug fixes.[ ] I have adjusted the documentation in./docs/source/
.Fixes:
annotations to PR description.