Class: DRbDump::MessageResult
- Defined in:
- lib/drbdump/message_result.rb
Overview
Wraps a DRb message-result after consuming it from a stream.
Instance Method Summary collapse
-
#allocations ⇒ Object
The number of allocations required to load the result.
-
#display ⇒ Object
Prints the message information to standard output.
-
#initialize(drbdump, packet, status, stream) ⇒ MessageResult
constructor
Creates a new MessageResult for the creating
drbdump
instance. -
#result ⇒ Object
The loaded result object.
-
#status ⇒ Object
The loaded status object.
-
#timestamp ⇒ Object
The timestamp of the last packet in the result.
-
#update_statistics ⇒ Object
Updates the drbdump’s statistics with information from this result.
Methods inherited from Message
#destination, from_stream, #resolve_addresses, #source
Constructor Details
#initialize(drbdump, packet, status, stream) ⇒ MessageResult
Creates a new MessageResult for the creating drbdump
instance. The last packet in the message is packet
and the Marshal::Structure for the result type is status
. The rest of the message will be loaded from stream
.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/drbdump/message_result.rb', line 12 def initialize drbdump, packet, status, stream super drbdump, packet @result = nil @status = nil @stream = stream @raw_result = @loader.load stream @raw_status = status end |
Instance Method Details
#allocations ⇒ Object
The number of allocations required to load the result.
26 27 28 |
# File 'lib/drbdump/message_result.rb', line 26 def allocations @raw_status.count_allocations + @raw_result.count_allocations end |
#display ⇒ Object
Prints the message information to standard output
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/drbdump/message_result.rb', line 33 def display update_statistics return if @drbdump.quiet = status ? 'success' : 'exception' arrow = status ? "\u21d0" : "\u2902" = self..strftime DRbDump::TIMESTAMP_FORMAT puts "%s %s %s %s %s: %s" % [ , destination, arrow, source, , result ] end |
#result ⇒ Object
The loaded result object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/drbdump/message_result.rb', line 50 def result return @result if @result result = @drbdump.load_marshal_data @raw_result @result = if DRb::DRbObject === result then "(\"druby://#{result.__drburi}\", #{result.__drbref})" else result.inspect end end |
#status ⇒ Object
The loaded status object
65 66 67 |
# File 'lib/drbdump/message_result.rb', line 65 def status @status ||= @raw_status.load end |
#timestamp ⇒ Object
The timestamp of the last packet in the result
72 73 74 |
# File 'lib/drbdump/message_result.rb', line 72 def @packet. end |
#update_statistics ⇒ Object
Updates the drbdump’s statistics with information from this result.
79 80 81 |
# File 'lib/drbdump/message_result.rb', line 79 def update_statistics # :nodoc: @statistics.add_result self end |