Class: JetstreamBridge::ConsumerMiddleware::ErrorHandlingMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/jetstream_bridge/consumer/middleware.rb

Overview

Error handling middleware with configurable retry logic

Examples:

consumer.use(JetstreamBridge::Consumer::ErrorHandlingMiddleware.new(
  on_error: ->(event, error) { Sentry.capture_exception(error) }
))

Instance Method Summary collapse

Constructor Details

#initialize(on_error: nil) ⇒ ErrorHandlingMiddleware



74
75
76
# File 'lib/jetstream_bridge/consumer/middleware.rb', line 74

def initialize(on_error: nil)
  @on_error = on_error
end

Instance Method Details

#call(event) ⇒ Object



78
79
80
81
82
83
# File 'lib/jetstream_bridge/consumer/middleware.rb', line 78

def call(event)
  yield
rescue StandardError => e
  @on_error&.call(event, e)
  raise
end