Class: Pgq::Event
- Inherits:
-
Object
- Object
- Pgq::Event
- Defined in:
- lib/pgq/event.rb
Instance Attribute Summary collapse
-
#consumer ⇒ Object
readonly
Returns the value of attribute consumer.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#exception_message(e) ⇒ Object
Prepare string with exception details.
- #failed!(ex) ⇒ Object
-
#initialize(consumer, event) ⇒ Event
constructor
A new instance of Event.
- #retry!(seconds = 0) ⇒ Object
Constructor Details
#initialize(consumer, event) ⇒ Event
Returns a new instance of Event.
4 5 6 7 8 9 |
# File 'lib/pgq/event.rb', line 4 def initialize(consumer, event) @id = event['ev_id'] @type = event['ev_type'] @consumer = consumer @data = @consumer.coder.load(event['ev_data']) if event['ev_data'] end |
Instance Attribute Details
#consumer ⇒ Object (readonly)
Returns the value of attribute consumer.
2 3 4 |
# File 'lib/pgq/event.rb', line 2 def consumer @consumer end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
2 3 4 |
# File 'lib/pgq/event.rb', line 2 def data @data end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
2 3 4 |
# File 'lib/pgq/event.rb', line 2 def id @id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
2 3 4 |
# File 'lib/pgq/event.rb', line 2 def type @type end |
Class Method Details
.exception_message(e) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/pgq/event.rb', line 20 def self.(e) <<-EXCEPTION Exception happend Error occurs: #{e.class.inspect}(#{e.}) Backtrace: #{e.backtrace.join("\n") rescue ''} EXCEPTION end |
Instance Method Details
#exception_message(e) ⇒ Object
Prepare string with exception details
29 30 31 32 33 34 35 36 37 |
# File 'lib/pgq/event.rb', line 29 def (e) <<-EXCEPTION Exception happend Type: #{@type.inspect} Data: #{@data.inspect} Error occurs: #{e.class.inspect}(#{e.}) Backtrace: #{e.backtrace.join("\n") rescue ''} EXCEPTION end |
#failed!(ex) ⇒ Object
11 12 13 14 |
# File 'lib/pgq/event.rb', line 11 def failed!(ex) h = {:class => ex.class.to_s, :message => ex., :backtrace => ex.backtrace} @consumer.event_failed @id, @consumer.coder.dump(h) end |
#retry!(seconds = 0) ⇒ Object
16 17 18 |
# File 'lib/pgq/event.rb', line 16 def retry!(seconds = 0) @consumer.event_retry(@id, seconds) end |