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:
Diffstat (limited to 'lib/gitlab/event_store/store.rb')
-rw-r--r--lib/gitlab/event_store/store.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/gitlab/event_store/store.rb b/lib/gitlab/event_store/store.rb
index 318745cc192..c558362122b 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, delay: nil)
+ def subscribe(worker, to:, if: nil, delay: nil, group_size: nil)
condition = binding.local_variable_get('if')
Array(to).each do |event|
validate_subscription!(worker, event)
- subscriptions[event] << Gitlab::EventStore::Subscription.new(worker, condition, delay)
+ subscriptions[event] << Gitlab::EventStore::Subscription.new(worker, condition, delay, group_size)
end
end
@@ -34,6 +34,18 @@ module Gitlab
end
end
+ def publish_group(events)
+ event_class = events.first.class
+
+ unless events.all? { |e| e.class < Event && e.instance_of?(event_class) }
+ raise InvalidEvent, "Not all events being published are valid"
+ end
+
+ subscriptions.fetch(event_class, []).each do |subscription|
+ subscription.consume_events(events)
+ end
+ end
+
private
def lock!