Use Celery instead of RQ.

Celery provides a more robust set of queueing options for both tasks and
worker processes. Updates include:
- infrastructure necessary to run Celery, including celery entrypoint
- backgrounded functions are now imported directly from atst.jobs
- update tests as-needed
- update kubernetes worker pod command
This commit is contained in:
dandds
2019-08-22 11:55:00 -04:00
parent b7f8152cc1
commit d7478e322a
18 changed files with 209 additions and 191 deletions

View File

@@ -1,6 +1,6 @@
from sqlalchemy import select
from atst.queue import ATSTQueue
from atst.jobs import send_notification_mail
from atst.database import db
from atst.models import NotificationRecipient
@@ -8,12 +8,9 @@ from atst.models import NotificationRecipient
class NotificationSender(object):
EMAIL_SUBJECT = "ATST notification"
def __init__(self, queue: ATSTQueue):
self.queue = queue
def send(self, body, type_=None):
recipients = self._get_recipients(type_)
self.queue.send_notification_mail(recipients, self.EMAIL_SUBJECT, body)
send_notification_mail.delay(recipients, self.EMAIL_SUBJECT, body)
def _get_recipients(self, type_):
query = select([NotificationRecipient.email])