Module: RailsPipeline::Emitter::InstanceMethods
- Defined in:
- lib/rails-pipeline/emitter.rb
Instance Method Summary collapse
- #create_message(version, event_type) ⇒ Object
- #emit(event_type = RailsPipeline::EncryptedMessage::EventType::CREATED) ⇒ Object
- #emit_on_create ⇒ Object
- #emit_on_destroy ⇒ Object
- #emit_on_update ⇒ Object
Instance Method Details
#create_message(version, event_type) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/rails-pipeline/emitter.rb', line 53 def (version, event_type) topic = self.class.topic_name(version) RailsPipeline.logger.debug "Emitting to #{topic}" data = self.send("to_pipeline_#{version}") enc_data = self.class.encrypt(data.to_s, type_info: data.class.name, topic: topic, event_type: event_type) return enc_data end |
#emit(event_type = RailsPipeline::EncryptedMessage::EventType::CREATED) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rails-pipeline/emitter.rb', line 36 def emit(event_type = RailsPipeline::EncryptedMessage::EventType::CREATED) if ENV.has_key?("DISABLE_RAILS_PIPELINE") || ENV.has_key?("DISABLE_RAILS_PIPELINE_EMISSION") RailsPipeline.logger.debug "Skipping outgoing pipeline messages (disabled by env vars)" return end begin self.class.pipeline_versions.each do |version| enc_data = (version, event_type) self.publish(enc_data.topic, enc_data.to_s) end rescue Exception => e RailsPipeline.logger.error("Error during emit(): #{e}") puts e.backtrace.join("\n") raise e end end |
#emit_on_create ⇒ Object
24 25 26 |
# File 'lib/rails-pipeline/emitter.rb', line 24 def emit_on_create emit(:create) end |
#emit_on_destroy ⇒ Object
32 33 34 |
# File 'lib/rails-pipeline/emitter.rb', line 32 def emit_on_destroy emit(:destroy) end |
#emit_on_update ⇒ Object
28 29 30 |
# File 'lib/rails-pipeline/emitter.rb', line 28 def emit_on_update emit(:update) end |