Commit e327f66c authored by Fabio Pitino's avatar Fabio Pitino

Log arguments of event store subscriber

Ensure we log string arguments the subscribers receives.
Remove the need to `include ApplicationWorker` for each
subscriber. We now include ApplicationWorker once in the
EventStore::Subscriber class.
parent 0b2afcd3
......@@ -2,7 +2,6 @@
module MergeRequests
class UpdateHeadPipelineWorker
include ApplicationWorker
include Gitlab::EventStore::Subscriber
feature_category :code_review
......
......@@ -232,7 +232,6 @@ the event safely via the `handle_event` method. For example:
```ruby
module MergeRequests
class UpdateHeadPipelineWorker
include ApplicationWorker
include Gitlab::EventStore::Subscriber
def handle_event(event)
......
......@@ -2,7 +2,6 @@
module GitlabSubscriptions
class NotifySeatsExceededWorker
include ApplicationWorker
include Gitlab::EventStore::Subscriber
feature_category :purchase
......
......@@ -7,7 +7,6 @@
#
# @example:
# class SomeEventSubscriber
# include ApplicationWorker
# include Gitlab::EventStore::Subscriber
#
# def handle_event(event)
......@@ -18,6 +17,14 @@
module Gitlab
module EventStore
module Subscriber
extend ActiveSupport::Concern
included do
include ApplicationWorker
loggable_arguments 0, 1
end
def perform(event_type, data)
raise InvalidEvent, event_type unless self.class.const_defined?(event_type)
......
......@@ -10,7 +10,6 @@ RSpec.describe Gitlab::EventStore::Store do
let(:worker) do
stub_const('EventSubscriber', Class.new).tap do |klass|
klass.class_eval do
include ApplicationWorker
include Gitlab::EventStore::Subscriber
def handle_event(event)
......@@ -23,7 +22,6 @@ RSpec.describe Gitlab::EventStore::Store do
let(:another_worker) do
stub_const('AnotherEventSubscriber', Class.new).tap do |klass|
klass.class_eval do
include ApplicationWorker
include Gitlab::EventStore::Subscriber
end
end
......@@ -32,7 +30,6 @@ RSpec.describe Gitlab::EventStore::Store do
let(:unrelated_worker) do
stub_const('UnrelatedEventSubscriber', Class.new).tap do |klass|
klass.class_eval do
include ApplicationWorker
include Gitlab::EventStore::Subscriber
end
end
......@@ -253,6 +250,10 @@ RSpec.describe Gitlab::EventStore::Store do
subject { worker_instance.perform(event_name, data) }
it 'is a Sidekiq worker' do
expect(worker_instance).to be_a(ApplicationWorker)
end
it 'handles the event' do
expect(worker_instance).to receive(:handle_event).with(instance_of(event.class))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment