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.
5 6 7 8 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 5 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
73 74 75 76 77 78 79 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 73 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
35 36 37 38 39 40 41 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 35 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
27 28 29 30 31 32 33 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 27 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
57 58 59 60 61 62 63 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 57 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
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 43 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, ) { broker.add_thread_subscription(subscriber, topics) } end end |
#all_subscriptions_for(topic) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 65 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
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 10 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
81 82 83 |
# File 'lib/ruby_event_store/instrumented_broker.rb', line 81 def respond_to_missing?(method_name, _include_private) broker.respond_to?(method_name) end |