Class: CycloneLariat::Middleware
- Inherits:
-
Object
- Object
- CycloneLariat::Middleware
- Defined in:
- lib/cyclone_lariat/middleware.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #call(_worker_instance, queue, _sqs_msg, body, &block) ⇒ Object
-
#initialize(errors_notifier: nil, message_notifier: nil, before_save: nil, repo: Repo::InboxMessages, **options) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(errors_notifier: nil, message_notifier: nil, before_save: nil, repo: Repo::InboxMessages, **options) ⇒ Middleware
Returns a new instance of Middleware.
13 14 15 16 17 18 19 |
# File 'lib/cyclone_lariat/middleware.rb', line 13 def initialize(errors_notifier: nil, message_notifier: nil, before_save: nil, repo: Repo::InboxMessages, **) @config = CycloneLariat::Options.wrap().merge!(CycloneLariat.config) @events_repo = repo.new(**@config.to_h) @message_notifier = @errors_notifier = errors_notifier @before_save = before_save end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/cyclone_lariat/middleware.rb', line 11 def config @config end |
Instance Method Details
#call(_worker_instance, queue, _sqs_msg, body, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cyclone_lariat/middleware.rb', line 21 def call(_worker_instance, queue, _sqs_msg, body, &block) msg = (body) &.info 'Receive message', message: msg, queue: queue return if msg.is_a? String catch_standard_error(queue, msg) do event = Messages::Builder.new(raw_message: msg).call store_in_dataset(event) do catch_business_error(event, &block) end end end |