Skip to content

Add policy event #4219

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

Merged
merged 4 commits into from
Jan 25, 2021
Merged

Conversation

jonathansamines
Copy link
Contributor

A event based approach to solve #4104 as suggested in #4210

@Nargonath Nargonath added the feature New functionality or improvement label Jan 15, 2021
Copy link
Member

@Nargonath Nargonath left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@kanongil kanongil 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 great. But there is one issue, which is that the policy event will also be emitted for server method caching.

Ie. either the docs need to be revised, or the implementation made to match the docs. I don't have an opinion on which approach will be better, so I hope you can offer which will work best for you. If you go with both, you could emit them on separate channels to differentiate it.

@kanongil
Copy link
Contributor

I would also like to note that adding a built-in event is potentially a breaking change since server.events is a public interface, and it could conflict with code that adds their own policy event.

That being said, this is a rarely used feature so a conflict is unlikely and if it does occur, it would most likely result in a very obvious error during server instantiation. As such, I would probably allow it without a major revision bump.

@Nargonath
Copy link
Member

Ie. either the docs need to be revised, or the implementation made to match the docs. I don't have an opinion on which approach will be better, so I hope you can offer which will work best for you. If you go with both, you could emit them on separate channels to differentiate it.

How would you go about differenciating them @kanongil in case you had something in mind?

@jonathansamines jonathansamines force-pushed the feature/cache-policy-event branch from a6efb6f to 500d0b5 Compare January 16, 2021 02:39
@jonathansamines
Copy link
Contributor Author

Ie. either the docs need to be revised, or the implementation made to match the docs. I don't have an opinion on which approach will be better, so I hope you can offer which will work best for you. If you go with both, you could emit them on separate channels to differentiate it.

Documentation updated. I am not sure how useful is to emit the event on separate channels though. As long as there is a policy involved, it wouldn't matter much how was it created. Thoughts?

Copy link
Contributor

@kanongil kanongil left a comment

Choose a reason for hiding this comment

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

Great. If you don't need to distinguish them, then we can leave it as is. Channels / tags can always be added later when needed.

Only missing a test for triggering the policy event for a cached server method now.

@jonathansamines
Copy link
Contributor Author

jonathansamines commented Jan 18, 2021

Tests for cached server methods added. CI failures seem unrelated to these changes.

Copy link
Member

@devinivy devinivy left a comment

Choose a reason for hiding this comment

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

Looks good 👍 I re-ran the tests, noting the flaky failures for further inspection, and everything is passing. Thanks for the careful work on this, everyone. I know several folks were following along who were not actively commenting on the related issues, self included.

@devinivy
Copy link
Member

Apologies for the late thought and potential request, but how do folks feel about changing the event name to 'cachePolicy' to avoid ambiguity? The term "policy" has meaning in catbox, but otherwise it is a generic term that might be hard to understand for users, especially because this term isn't referenced in the hapi API. @nlf brought this up originally in conversation and might have further thoughts.

@kanongil
Copy link
Contributor

I agree with your points, and had a similar idea for the name. I settled on 'policy' for consistence with the existing hapi apis that seem to prefer succinct names whenever possible, and assumed that it would be challenged if anyone felt that it was an issue.

Given that this will be a rarely used event, cachePolicy should work fine, and makes it even more unlikely that it conflicts. Camel casing seems appropriate, and mirrors how node itself does it.

@Nargonath
Copy link
Member

I agree with both of you. Renaming it is a good idea.

@jonathansamines
Copy link
Contributor Author

Agreed. Changes applied.

Copy link
Member

@devinivy devinivy left a comment

Choose a reason for hiding this comment

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

Beautiful. Thanks for all the careful work @jonathansamines 🙏

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

Successfully merging this pull request may close these issues.

4 participants