Class: Axn::Webhooks::Dispatch
- Inherits:
-
Object
- Object
- Axn::Webhooks::Dispatch
- Includes:
- Axn, VendorFacet
- Defined in:
- lib/axn/webhooks/dispatch.rb
Overview
Routes a verified request to its handler Axn. Built as an Axn so every loud failure
(missing handler, unmatched key, parse error, handler crash, or an async enqueue with no
adapter configured) lands in axn's exception bucket — reported once via on_exception,
returned as a formatted result — and a handler business fail! stays a quiet failure.
Instance Method Summary collapse
Methods included from VendorFacet
Instance Method Details
#call ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/axn/webhooks/dispatch.rb', line 23 def call event = parse_event resolution = router.resolve(event) return done!("acknowledged") if resolution == :ack handler_class, args, route_async = resolution return dispatch_async(handler_class, args) if async?(handler_class, route_async) expose handler_result: nil expose handler_result: handler_class.call!(**args) rescue Axn::Webhooks::RetryLater => e # Rescued for the whole method, not just the handler call: a `parse:` proc that does I/O needs # the same "come back later" escape hatch, now that everything else it raises is terminal (see # #parse_event) — and a RetryLater from a `with:` extractor or an `otherwise:` callable means # the same thing wherever it's raised. handler_result is left unexposed (allow_nil) whenever # the deferral happens before the handler ran. expose retry_later: true expose retry_after: e.retry_after end |