Class: Pgbus::EventBus::Handler
- Inherits:
-
Object
- Object
- Pgbus::EventBus::Handler
- Defined in:
- lib/pgbus/event_bus/handler.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.dedup_cache ⇒ Object
15 16 17 |
# File 'lib/pgbus/event_bus/handler.rb', line 15 def dedup_cache @dedup_cache ||= DedupCache.new end |
.idempotent! ⇒ Object
7 8 9 |
# File 'lib/pgbus/event_bus/handler.rb', line 7 def idempotent! @idempotent = true end |
.idempotent? ⇒ Boolean
11 12 13 |
# File 'lib/pgbus/event_bus/handler.rb', line 11 def idempotent? @idempotent == true end |
Instance Method Details
#handle(event) ⇒ Object
31 32 33 |
# File 'lib/pgbus/event_bus/handler.rb', line 31 def handle(event) raise NotImplementedError, "#{self.class.name} must implement #handle(event)" end |
#process(message) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pgbus/event_bus/handler.rb', line 20 def process() raw = JSON.parse(.) event = build_event(raw) return :skipped if self.class.idempotent? && !claim_idempotency?(event.event_id) handle(event) instrument("pgbus.event_processed", event_id: event.event_id, handler: self.class.name) :handled end |