Class: RailwayIpc::ConsumedMessage
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- RailwayIpc::ConsumedMessage
- Defined in:
- lib/railway_ipc/models/consumed_message.rb
Constant Summary collapse
- STATUS_SUCCESS =
'success'
- STATUS_PROCESSING =
'processing'
- STATUS_IGNORED =
'ignored'
- STATUS_UNKNOWN_MESSAGE_TYPE =
'unknown_message_type'
- STATUS_FAILED_TO_PROCESS =
'failed_to_process'
- VALID_STATUSES =
[ STATUS_SUCCESS, STATUS_PROCESSING, STATUS_IGNORED, STATUS_UNKNOWN_MESSAGE_TYPE, STATUS_FAILED_TO_PROCESS ].freeze
Instance Attribute Summary collapse
-
#decoded_message ⇒ Object
readonly
Returns the value of attribute decoded_message.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#decoded_message ⇒ Object (readonly)
Returns the value of attribute decoded_message.
19 20 21 |
# File 'lib/railway_ipc/models/consumed_message.rb', line 19 def @decoded_message end |
Class Method Details
.create_processing(consumer, incoming_message) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/railway_ipc/models/consumed_message.rb', line 26 def self.create_processing(consumer, ) # rubocop:disable Style/RedundantSelf self.create!( uuid: .uuid, status: STATUS_PROCESSING, message_type: .type, user_uuid: .user_uuid, correlation_id: .correlation_id, queue: consumer.queue_name, exchange: consumer.exchange_name, encoded_message: .payload ) # rubocop:enable Style/RedundantSelf end |
Instance Method Details
#processed? ⇒ Boolean
49 50 51 52 53 |
# File 'lib/railway_ipc/models/consumed_message.rb', line 49 def processed? # rubocop:disable Style/RedundantSelf self.status == STATUS_SUCCESS # rubocop:enable Style/RedundantSelf end |
#update_with_lock(job) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/railway_ipc/models/consumed_message.rb', line 41 def update_with_lock(job) with_lock('FOR UPDATE NOWAIT') do job.run self.status = job.status save end end |