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

Disambiguate whether a revalidator recognized a request when checking for a need to revalidate #87

Merged
merged 2 commits into from
Sep 29, 2020

Conversation

hannahhoward
Copy link
Collaborator

Goals

Previously, the revalidators were very ambiguous in identifying if they had actually handled a
request for a revalidation check or not -- a "nil, nil" or "voucher result, nil" was interpreted as
not being handled. This is unfortunate, cause particularly a "voucher result, nil" is an indication
the request is handled by this check, and we should stop processing other revalidators that might
override the value with "nil, nil". While we could technically stop on a "voucher result, nil" -- it seems best to just make explicit whether we did or did not handle the request.

Implementation

Add a boolean to disambiguate whether the revalidator "recognized" a request for OnPushDateReceived, OnPullDataSent, and OnComplete

Copy link
Collaborator

@aarshkshah1992 aarshkshah1992 left a comment

Choose a reason for hiding this comment

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

LGTM except typos and one question.

manager.go Outdated
// for a given pull request. It should return a VoucherResult + ErrPause to
// for a given pull request. The first value indicates whether the request was
// recognized by this revalidator and should be considered 'handled'. If true,
// the remaining to values are interpreted. If 'false' the request is passed on
Copy link
Collaborator

Choose a reason for hiding this comment

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

remaining two*

Copy link
Collaborator

Choose a reason for hiding this comment

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

This typo needs to be fixed below as well.

return err
handled, result, err = revalidator.OnPushDataReceived(chid, size)
if handled {
return errors.New("stop processing")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to return this error ? So that we break the m.revalidators.Each loop ?

Is there any other significance of this error ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yea that's what it does -- it stops the loop -- note that it's ignored in the return

Previously, the revalidators were very ambiguous in identifying if they had actually handled a
request for a revalidation check or not -- a "nil, nil" or "voucher result, nil" was interpreted as
not being handled. This is unfortunate, cause particularly a "voucher result, nil" is an indication
the request is handled by this check, and we should stop processing other revalidators that might
override the value with "nil, nil". We now add a boolean to disambiguate whether the revalidator
"recognized" this request --- if true, processing stops.
@hannahhoward hannahhoward force-pushed the feat/add-bool-to-revalidator-interfaces branch from f7d85bd to a400317 Compare September 29, 2020 09:52
@hannahhoward hannahhoward merged commit 8a1e460 into master Sep 29, 2020
hannahhoward added a commit that referenced this pull request Sep 29, 2020
* Disambiguate whether a revalidator recognized a request when checking for a need to revalidate (#87)

* feat(revalidator): add handled bool

Previously, the revalidators were very ambiguous in identifying if they had actually handled a
request for a revalidation check or not -- a "nil, nil" or "voucher result, nil" was interpreted as
not being handled. This is unfortunate, cause particularly a "voucher result, nil" is an indication
the request is handled by this check, and we should stop processing other revalidators that might
override the value with "nil, nil". We now add a boolean to disambiguate whether the revalidator
"recognized" this request --- if true, processing stops.

* style(comments): fix types

* feat(impl): cleanup errors

cleanup errors -- move more error codes to proper types and insure single error dispatched

* test(impl): add unit test for incomplete response
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.

2 participants