Class: ActiveRecord::ConnectionAdapters::QueryIntent::EventBuffer
| Relationships & Source Files | |
| Namespace Children | |
|
Classes:
| |
| Inherits: | Object |
| Defined in: | activerecord/lib/active_record/connection_adapters/query_intent.rb |
Overview
Buffers instrumentation events during background execution for later publishing
Class Method Summary
- .new(intent, instrumenter) ⇒ EventBuffer constructor
Instance Method Summary
Constructor Details
.new(intent, instrumenter) ⇒ EventBuffer
# File 'activerecord/lib/active_record/connection_adapters/query_intent.rb', line 12
def initialize(intent, instrumenter) @intent = intent @instrumenter = instrumenter @events = [] end
Instance Method Details
#add_event(event)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/query_intent.rb', line 31
def add_event(event) @events << event end
#build_handle(name, payload)
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/query_intent.rb', line 27
def build_handle(name, payload) DeferredHandle.new(self, @instrumenter, name, payload) end
#flush
[ GitHub ]# File 'activerecord/lib/active_record/connection_adapters/query_intent.rb', line 35
def flush events, @events = @events, [] events.each do |event| event.payload[:lock_wait] = @intent.lock_wait ActiveSupport::Notifications.publish_event(event) end end