Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-09-20 14:18:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-09-20 14:18:08 +0300
commit5afcbe03ead9ada87621888a31a62652b10a7e4f (patch)
tree9918b67a0d0f0bafa6542e839a8be37adf73102d /lib/gitlab/event_store
parentc97c0201564848c1f53226fe19d71fdcc472f7d0 (diff)
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'lib/gitlab/event_store')
-rw-r--r--lib/gitlab/event_store/store.rb4
-rw-r--r--lib/gitlab/event_store/subscription.rb11
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/gitlab/event_store/store.rb b/lib/gitlab/event_store/store.rb
index 2e5e0215687..318745cc192 100644
--- a/lib/gitlab/event_store/store.rb
+++ b/lib/gitlab/event_store/store.rb
@@ -15,12 +15,12 @@ module Gitlab
lock!
end
- def subscribe(worker, to:, if: nil)
+ def subscribe(worker, to:, if: nil, delay: nil)
condition = binding.local_variable_get('if')
Array(to).each do |event|
validate_subscription!(worker, event)
- subscriptions[event] << Gitlab::EventStore::Subscription.new(worker, condition)
+ subscriptions[event] << Gitlab::EventStore::Subscription.new(worker, condition, delay)
end
end
diff --git a/lib/gitlab/event_store/subscription.rb b/lib/gitlab/event_store/subscription.rb
index 01986355d2d..81a65f9a8ff 100644
--- a/lib/gitlab/event_store/subscription.rb
+++ b/lib/gitlab/event_store/subscription.rb
@@ -3,17 +3,22 @@
module Gitlab
module EventStore
class Subscription
- attr_reader :worker, :condition
+ attr_reader :worker, :condition, :delay
- def initialize(worker, condition)
+ def initialize(worker, condition, delay)
@worker = worker
@condition = condition
+ @delay = delay
end
def consume_event(event)
return unless condition_met?(event)
- worker.perform_async(event.class.name, event.data.deep_stringify_keys)
+ if delay
+ worker.perform_in(delay, event.class.name, event.data.deep_stringify_keys)
+ else
+ worker.perform_async(event.class.name, event.data.deep_stringify_keys)
+ end
# We rescue and track any exceptions here because we don't want to
# impact other subscribers if one is faulty.