summaryrefslogtreecommitdiff
path: root/app/services/issues/close_service.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2018-04-20 19:37:38 +0200
committerSean McGivern <sean@gitlab.com>2018-04-25 12:48:14 +0100
commitb5042e5301e86ec7822221ee29679b0fbf5c71ca (patch)
tree48d02d3b6b52c94015d5bb6509db3807056e3dff /app/services/issues/close_service.rb
parentfd532302ecb04159ce1299f1b312fe622147849c (diff)
downloadgitlab-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/close_service.rb')
-rw-r--r--app/services/issues/close_service.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/services/issues/close_service.rb b/app/services/issues/close_service.rb
index fee5bc38f7b..4a99367c575 100644
--- a/app/services/issues/close_service.rb
+++ b/app/services/issues/close_service.rb
@@ -26,7 +26,7 @@ module Issues
issue.update(closed_by: current_user)
event_service.close_issue(issue, current_user)
create_note(issue, commit) if system_note
- notification_service.close_issue(issue, current_user) if notifications
+ notification_service.async.close_issue(issue, current_user) if notifications
todo_service.close_issue(issue, current_user)
execute_hooks(issue, 'close')
invalidate_cache_counts(issue, users: issue.assignees)