-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add signal reservations #2060
Add signal reservations #2060
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2060 +/- ##
=============================================
+ Coverage 92.176% 92.190% +0.014%
=============================================
Files 38 38
Lines 3451 3457 +6
Branches 580 581 +1
=============================================
+ Hits 3181 3187 +6
Misses 184 184
Partials 86 86
Continue to review full report at Codecov.
|
Is the thought that the user might want to handle potential future |
sanic/signals.py
Outdated
if reservation.reference is None or reservation.action is None: | ||
continue |
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.
reservation.reference
cannot be None here. We call reservation.reference.split(",")
above, so it must be a string. It it was None
, Line 158 would throw and exception.
Do we need to move if reservation.reference is None: continue
to above line 155?
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.
Good catch. Again, maybe I am overcomplicating and the whole thing should just be:
parts = event.split(",")
if parts[0] in ("server", "http", "sanic"):
raise InvalidSignal
And then worry about any more complicated logic when we get to it.
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.
Yep. I'd go with the simpler solution for now. We can think about reservation rules and how they are matched against signals, in the future.
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.
Okay, I updated it to only be reserved namespaces http
and server
.
I want to push people (via the docs) to get used to using sanic.notice.something
when they have a simple use case and a full blown namespaced event doesn't make sense.
I think these might be names we want to control. Probably also |
It occurred to me while writing documentation for #1630/#2042 that there were certain patterns of names that we probably do not want people to start declaring on their own. We do not know exactly what those patterns are yet, but I thought it might make sense to lock in some reserved names so people do not start implementing them now, and then end up with weird behaviors down the road.
Basically, that means we are adding some code right now that will be temporary. Or, at the very least will change.
Perhaps I am being overly cautious. Thoughts? Do we need this? Is the list complete enough for now?
Current reservations:
server.
http.
Anything startingsanic.
that is notsanic.notice.
orsanic.log.