Class: RubyEventStore::InstrumentedRepository
- Inherits:
-
Object
- Object
- RubyEventStore::InstrumentedRepository
- Defined in:
- lib/ruby_event_store/instrumented_repository.rb
Instance Method Summary collapse
- #append_to_stream(records, stream, expected_version) ⇒ Object
- #count(specification) ⇒ Object
- #delete_stream(stream) ⇒ Object
-
#initialize(repository, instrumentation) ⇒ InstrumentedRepository
constructor
A new instance of InstrumentedRepository.
- #link_to_stream(event_ids, stream, expected_version) ⇒ Object
- #method_missing(method_name, *arguments, **keyword_arguments, &block) ⇒ Object
- #read(specification) ⇒ Object
- #respond_to_missing?(method_name, _include_private) ⇒ Boolean
- #streams_of(event_id) ⇒ Object
- #update_messages(records) ⇒ Object
Constructor Details
#initialize(repository, instrumentation) ⇒ InstrumentedRepository
Returns a new instance of InstrumentedRepository.
5 6 7 8 |
# File 'lib/ruby_event_store/instrumented_repository.rb', line 5 def initialize(repository, instrumentation) @repository = repository @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_repository.rb', line 73 def method_missing(method_name, *arguments, **keyword_arguments, &block) if respond_to?(method_name) repository.public_send(method_name, *arguments, **keyword_arguments, &block) else super end end |
Instance Method Details
#append_to_stream(records, stream, expected_version) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby_event_store/instrumented_repository.rb', line 10 def append_to_stream(records, stream, expected_version) instrumentation.instrument( "append_to_stream.repository.ruby_event_store", records: records, events: records, stream: stream, ) do deprecated_instrument( "append_to_stream.repository.rails_event_store", { records: records, events: records, stream: stream }, ) { repository.append_to_stream(records, stream, expected_version) } end end |
#count(specification) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/ruby_event_store/instrumented_repository.rb', line 48 def count(specification) instrumentation.instrument("count.repository.ruby_event_store", specification: specification) do deprecated_instrument("count.repository.rails_event_store", specification: specification) do repository.count(specification) end end end |
#delete_stream(stream) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/ruby_event_store/instrumented_repository.rb', line 32 def delete_stream(stream) instrumentation.instrument("delete_stream.repository.ruby_event_store", stream: stream) do deprecated_instrument("delete_stream.repository.rails_event_store", stream: stream) do repository.delete_stream(stream) end end end |
#link_to_stream(event_ids, stream, expected_version) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/ruby_event_store/instrumented_repository.rb', line 24 def link_to_stream(event_ids, stream, expected_version) instrumentation.instrument("link_to_stream.repository.ruby_event_store", event_ids: event_ids, stream: stream) do deprecated_instrument("link_to_stream.repository.rails_event_store", event_ids: event_ids, stream: stream) do repository.link_to_stream(event_ids, stream, expected_version) end end end |
#read(specification) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/ruby_event_store/instrumented_repository.rb', line 40 def read(specification) instrumentation.instrument("read.repository.ruby_event_store", specification: specification) do deprecated_instrument("read.repository.rails_event_store", specification: specification) do repository.read(specification) end end end |
#respond_to_missing?(method_name, _include_private) ⇒ Boolean
81 82 83 |
# File 'lib/ruby_event_store/instrumented_repository.rb', line 81 def respond_to_missing?(method_name, _include_private) repository.respond_to?(method_name) end |
#streams_of(event_id) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/ruby_event_store/instrumented_repository.rb', line 65 def streams_of(event_id) instrumentation.instrument("streams_of.repository.ruby_event_store", event_id: event_id) do deprecated_instrument("streams_of.repository.rails_event_store", event_id: event_id) do repository.streams_of(event_id) end end end |
#update_messages(records) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/ruby_event_store/instrumented_repository.rb', line 56 def (records) instrumentation.instrument("update_messages.repository.ruby_event_store", records: records, messages: records) do deprecated_instrument( "update_messages.repository.rails_event_store", { records: records, messages: records }, ) { repository.(records) } end end |