Navigation Menu

Skip to content

Commit

Permalink
Export number of forecasted and received messages
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 17, 2015
1 parent 262c856 commit 03c30e5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/drndump/dump_client.rb
Expand Up @@ -19,6 +19,7 @@

module Drndump
class DumpClient
attr_reader :n_forecasted_messages, :n_received_messages
attr_reader :error_message
attr_writer :on_finish, :on_progress, :on_error

Expand All @@ -43,6 +44,9 @@ def initialize(params)
@receiver_host = params[:receiver_host]
@receiver_port = params[:receiver_port]

@n_forecasted_messages = 0
@n_received_messages = 0

@error_message = nil

@on_finish = nil
Expand Down Expand Up @@ -88,12 +92,15 @@ def run(options={}, &block)
@error_message = "#{error['name']}: #{error['message']}"
end
when "dump.table"
@n_received_messages += 1
table_create_message = convert_to_table_create_message(message)
yield(table_create_message)
when "dump.column"
@n_received_messages += 1
column_create_message = convert_to_column_create_message(message)
yield(column_create_message)
when "dump.record"
@n_received_messages += 1
add_message = message.dup
add_message.delete("inReplyTo")
add_message["type"] = "add"
Expand All @@ -106,6 +113,8 @@ def run(options={}, &block)
client.close
on_finish
end
when "dump.forecast"
@n_forecasted_messages += message["body"]["nMessages"]
end
when NilClass
client.close
Expand Down

0 comments on commit 03c30e5

Please sign in to comment.