-
Notifications
You must be signed in to change notification settings - Fork 13
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
Use django-q2 for notifications #630
base: master
Are you sure you want to change the base?
Conversation
Missing:
|
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
bbd742a
to
2b41824
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #630 +/- ##
==========================================
+ Coverage 84.61% 84.70% +0.09%
==========================================
Files 75 75
Lines 3750 3754 +4
==========================================
+ Hits 3173 3180 +7
+ Misses 577 574 -3 ☔ View full report in Codecov by Sentry. |
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.
This looks like you're on the right track. I got this to work with only slight modifications.
I added an extra qcluster
service to docker-compose.yml
, which basically is a copy of api
, but which executes the manage.py qcluster
command rather than daphne, and can get it to dispatch notifications according to my profile when I inject fake ones.
i.e. it's usable, but I don't like the redundant environment definitions in |
I've looked at bulk-changes ( Should we make one notification per change (easy, by putting the new events on the queue one at a time) or should we make a single notification for a "bulk-change"-event? The problem with the latter is matching it with filters: a filter might hit one of the events in the bulk, but not all of them. |
I like the easy and less complicated route of one queued job per notification. It shouldn't become a bottleneck, but if it does, we can work it out later. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
eb7fa00
to
9a0fd3c
Compare
Quality Gate passedIssues Measures |
4206b6a
to
f59ae53
Compare
This sets up the API web server and the Django Q2 qcluster command as separate Docker Compose services, based on the same image and config. The only difference between the two containers is which command they run. The image defaults to the API entrypoint, while docker-compose.yml will override the command of the qcluster service. In an attempt to make it DRY, the two nearly-identical services are templated out using YAML anchors and X properties, as suggested by the Docker Compose docs.
Quality Gate passedIssues Measures |
Closes #400
Note that django-q2 won't even install on python 3.7.
Dependencies
There's a new one, so remember to install django-q2 in the venv.
Database
Depending on
django_q2
adds new database tables, so migrations must be run:Redis
It currently uses redis, the same redis that is configured for websockets, so set the environment-variable
ARGUS_REDIS_SERVER
. This is used to make the redis-settings insrc/argus/site/settings/base.py
, settingQ_CLUSTER
. Override in local settings if necessary.Running django-q2
Start the brokers with
It does not run in the background and can be turned off with
Ctrl-C.
Note: if any changes are made to the code, qcluster must be restarted, it does not automatically discover changes.Check if a task worked or failed in Django Admin, the "Django Q2 Queue"-section.
Test sending notifications
Test queuing notifications by
EMAIL_BACKEND
is'django.core.mail.backends.console.EmailBackend'
, this pumps the contents of the email to the console/sys.stdout whereqcluster
is running.python manage.py create_fake_incident
In the terminal where you do step 3, the last log-line will contain something like:
"Notification: will be sending notification for "'Incident start':..".
In the terminal where qcluster is running, you'll get a log line starting with "Notification: sending event "'Incident start':..". The header and body will be dumped as plaintext after this line. After the email there will be a log line starting with "Notification: sent event "'Incident start':..".
Docker
The postgres image has been updated to version 13, this means the volume should be deleted and remade. Clean everything away with: