Class: InstagramConnect::Ingest::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/instagram_connect/ingest/dispatcher.rb

Overview

Walks a verified webhook payload, banks every event it contains on the ledger, and routes each one to its handler.

Two rules shape this class:

  1. Nothing is dropped. An event with no handler, or belonging to no connected account, still gets a row. Meta does not re-deliver, so a counter increment would be the only record that something was lost.
  2. One bad event cannot poison the batch. Each is wrapped in its own rescue and marked failed with its error, leaving the rest to process.

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Dispatcher

Returns a new instance of Dispatcher.



17
18
19
# File 'lib/instagram_connect/ingest/dispatcher.rb', line 17

def initialize(config)
  @config = config
end

Instance Method Details

#call(payload) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/instagram_connect/ingest/dispatcher.rb', line 21

def call(payload)
  summary = Summary.new
  Array(payload && payload["entry"]).each do |entry|
    process_entry(payload, entry, summary)
  end
  summary
end