Module: Rollgeist::Notifier

Defined in:
lib/rollgeist/notifier.rb

Constant Summary collapse

EVENT_NAME =
"ghost_access.rollgeist"
WATCHPOINT_BITS =
{
  serialization: 1,
  global_id: 2,
  resave: 4
}.freeze

Class Method Summary collapse

Class Method Details

.notify(record, watchpoint) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rollgeist/notifier.rb', line 13

def notify(record, watchpoint)
  return unless Rollgeist.enabled?
  return if Rollgeist.suppressed?

  configuration = Rollgeist.configuration
  return unless configuration.watchpoint_enabled?(watchpoint)

  mark = Rollgeist.mark_for(record)
  return unless mark

  report = Report.build(record: record, mark: mark, watchpoint: watchpoint)
  return if ignored?(configuration, report)
  return if configuration.warn_once && !claim_watchpoint(record, watchpoint)

  decision = ExecutionState.claim(configuration.max_reports_per_request)
  report_suppressed(decision.suppressed_to_flush) if decision.suppressed_to_flush
  return unless decision.allowed

  emit(report, configuration)
rescue GhostRecordAccess
  raise
rescue StandardError => error
  warn_safely("Rollgeist notifier failure: #{error.class}: #{error.message}")
end

.report_suppressed(count) ⇒ Object



38
39
40
41
42
# File 'lib/rollgeist/notifier.rb', line 38

def report_suppressed(count)
  return unless count.to_i.positive?

  log_safely("Rollgeist: +#{count} more suppressed")
end