-
Notifications
You must be signed in to change notification settings - Fork 79
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
Adds support for additional kwargs in middlewares (Solves issue #82) #83
Conversation
15e6603
to
e3e92e3
Compare
e3e92e3
to
b13d72e
Compare
@dnmellen thanks! I'll dig into this next weekend. |
django_dramatiq/apps.py
Outdated
@@ -36,13 +36,12 @@ class DjangoDramatiqConfig(AppConfig): | |||
name = "django_dramatiq" | |||
verbose_name = "Django Dramatiq" | |||
|
|||
@classmethod | |||
def initialize(cls): | |||
def ready(self): |
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.
@Bogdanp I think you have a nice reason to use the @classmethod
decorated initialize method. I tried my branch in my django project and some things were broken because the ready()
method runs too late. I'm going to modify this to keep using your initialize method.
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.
BTW with the latest changes, I could use the GroupCallbacks middleware successfully in my project.
Thanks again. This looks good, but would you mind adding an example to the |
No problem! I can change the |
@Bogdanp I added some documentation to the Thanks! |
cb0eb41
to
cc3607e
Compare
Thanks again. I made some minor changes on top and merged your changes with rebase. I'll cut a release in the next couple of weeks. |
I'm trying to make the middleware initialization more flexible by adding a hooks system to be able to override the initial kwargs for some middleware during the
django_dramatiq
app initialization.The way you would provide this hook would be by overriding
django_dramatiq
django conf:If you want to add
dramatiq.middleware.GroupCallbacks
middleware, the name of the hook would bemiddleware_groupcallbacks_kwargs
. It takes the middleware name and converts it to lowercase (middleware_<middlewarename>_kwargs
).The hook is a classmethod that returns a
dict
containing the kwargs for that middleware.I was completely unable to create tests for this feature without changing the current test settings, but these changes are not changing any functionality unless you override the
DjangoDramatiqConfig
.