diff options
author | Sean McGivern <sean@gitlab.com> | 2018-04-20 19:37:38 +0200 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-04-25 12:48:14 +0100 |
commit | b5042e5301e86ec7822221ee29679b0fbf5c71ca (patch) | |
tree | 48d02d3b6b52c94015d5bb6509db3807056e3dff /app/services/issues/reopen_service.rb | |
parent | fd532302ecb04159ce1299f1b312fe622147849c (diff) | |
download | gitlab-ce-b5042e5301e86ec7822221ee29679b0fbf5c71ca.tar.gz |
Move NotificationService calls to Sidekiq
The NotificationService has to do quite a lot of work to calculate the
recipients for an email. Where possible, we should try to avoid doing this in an
HTTP request, because the mail are sent by Sidekiq anyway, so there's no need to
schedule those emails immediately.
This commit creates a generic Sidekiq worker that uses Global ID to serialise
and deserialise its arguments, then forwards them to the NotificationService.
The NotificationService gains an `#async` method, so you can replace:
notification_service.new_issue(issue, current_user)
With:
notification_service.async.new_issue(issue, current_user)
And have everything else work as normal, except that calculating the recipients
will be done by Sidekiq, which will then schedule further Sidekiq jobs to send
each email.
Diffstat (limited to 'app/services/issues/reopen_service.rb')
-rw-r--r-- | app/services/issues/reopen_service.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/services/issues/reopen_service.rb b/app/services/issues/reopen_service.rb index 62b4b4b6a1e..02224f3357a 100644 --- a/app/services/issues/reopen_service.rb +++ b/app/services/issues/reopen_service.rb @@ -6,7 +6,7 @@ module Issues if issue.reopen event_service.reopen_issue(issue, current_user) create_note(issue, 'reopened') - notification_service.reopen_issue(issue, current_user) + notification_service.async.reopen_issue(issue, current_user) execute_hooks(issue, 'reopen') invalidate_cache_counts(issue, users: issue.assignees) issue.update_project_counter_caches |