Module: Upkeep::Subscriptions::LookupInstrumentation

Included in:
LayeredReverseIndex, MemoryReverseIndex
Defined in:
lib/upkeep/subscriptions/lookup_instrumentation.rb

Overview

Shared lookup instrumentation for the memory and layered reverse indexes: one notification name, one entries_for dispatch, one miss-reason rule. Including classes provide #lookup_store, #entries_for_with_payload and #entries_for_without_payload.

Constant Summary collapse

LOOKUP_NOTIFICATION =
"lookup_subscription_index.upkeep"

Instance Method Summary collapse

Instance Method Details

#entries_for(changes) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/upkeep/subscriptions/lookup_instrumentation.rb', line 14

def entries_for(changes)
  if ActiveSupport::Notifications.notifier.listening?(LOOKUP_NOTIFICATION)
    payload = { changes: Array(changes).size, store: lookup_store }
    ActiveSupport::Notifications.instrument(LOOKUP_NOTIFICATION, payload) do
      entries_for_with_payload(changes, payload)
    end
  else
    entries_for_without_payload(changes)
  end
end