Class: RubyEventStore::InstrumentedBroker
- Inherits:
-
Object
- Object
- RubyEventStore::InstrumentedBroker
- Defined in:
- lib/ruby_event_store/instrumented_broker.rb
Instance Method Summary collapse
- #add_global_subscription(subscriber) ⇒ Object
- #add_subscription(subscriber, topics) ⇒ Object
- #add_thread_global_subscription(subscriber) ⇒ Object
- #add_thread_subscription(subscriber, topics) ⇒ Object
- #all_subscriptions_for(topic) ⇒ Object
- #call(topic, event, record) ⇒ Object
-
#initialize(broker, instrumentation) ⇒ InstrumentedBroker
constructor
A new instance of InstrumentedBroker.
- #method_missing(method_name, *arguments, **keyword_arguments, &block) ⇒ Object
- #respond_to_missing?(method_name, _include_private) ⇒ Boolean
Constructor Details
#initialize(broker, instrumentation) ⇒ InstrumentedBroker
Returns a new instance of InstrumentedBroker.
11 12 13 14 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 11 def initialize(broker, instrumentation) @broker = broker @instrumentation = instrumentation end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, **keyword_arguments, &block) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 77 def method_missing(method_name, *arguments, **keyword_arguments, &block) if respond_to?(method_name) broker.public_send(method_name, *arguments, **keyword_arguments, &block) else super end end |
Instance Method Details
#add_global_subscription(subscriber) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 41 def add_global_subscription(subscriber) instrumentation.instrument("add_global_subscription.broker.ruby_event_store", subscriber: subscriber) do deprecated_instrument("add_global_subscription.broker.rails_event_store", subscriber: subscriber) do broker.add_global_subscription(subscriber) end end end |
#add_subscription(subscriber, topics) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 33 def add_subscription(subscriber, topics) instrumentation.instrument("add_subscription.broker.ruby_event_store", subscriber: subscriber, topics: topics) do deprecated_instrument("add_subscription.broker.rails_event_store", subscriber: subscriber, topics: topics) do broker.add_subscription(subscriber, topics) end end end |
#add_thread_global_subscription(subscriber) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 61 def add_thread_global_subscription(subscriber) instrumentation.instrument("add_thread_global_subscription.broker.ruby_event_store", subscriber: subscriber) do deprecated_instrument("add_thread_global_subscription.broker.rails_event_store", subscriber: subscriber) do broker.add_thread_global_subscription(subscriber) end end end |
#add_thread_subscription(subscriber, topics) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 49 def add_thread_subscription(subscriber, topics) instrumentation.instrument( "add_thread_subscription.broker.ruby_event_store", subscriber: subscriber, topics: topics, ) do deprecated_instrument("add_thread_subscription.broker.rails_event_store", subscriber: subscriber, topics: topics) do broker.add_thread_subscription(subscriber, topics) end end end |
#all_subscriptions_for(topic) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 69 def all_subscriptions_for(topic) instrumentation.instrument("all_subscriptions_for.broker.ruby_event_store", topic: topic) do deprecated_instrument("all_subscriptions_for.broker.rails_event_store", topic: topic) do broker.all_subscriptions_for(topic) end end end |
#call(topic, event, record) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 16 def call(topic, event, record) instrumentation.instrument("call.broker.ruby_event_store", topic: topic, event: event, record: record) do deprecated_instrument("call.broker.rails_event_store", topic: topic, event: event, record: record) do if broker.public_method(:call).arity == 3 broker.call(topic, event, record) else warn <<~EOW Message broker shall support topics. Topic WILL BE IGNORED in the current broker. Modify the broker implementation to pass topic as an argument to broker.call method. EOW broker.call(event, record) end end end end |
#respond_to_missing?(method_name, _include_private) ⇒ Boolean
85 86 87 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 85 def respond_to_missing?(method_name, _include_private) broker.respond_to?(method_name) end |