Navigation Menu

Skip to content

Commit

Permalink
Determine the number of messages per second by default
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 17, 2015
1 parent f20a42c commit 47ac7ab
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/drndump/dump_client.rb
Expand Up @@ -19,6 +19,8 @@

module Drndump
class DumpClient
DEFAULT_MESSAGES_PER_SECOND = 10000 # same to droogna-engine's one

attr_reader :n_forecasted_messages, :n_received_messages
attr_reader :error_message
attr_writer :on_finish, :on_progress, :on_error
Expand Down Expand Up @@ -46,6 +48,7 @@ def initialize(params)

@n_forecasted_messages = 0
@n_received_messages = 0
@n_messages_per_second = DEFAULT_MESSAGES_PER_SECOND

@error_message = nil

Expand All @@ -66,14 +69,15 @@ def run(options={}, &block)

n_dumpers = 0

dump_params = {}
if options[:messages_per_second]
dump_params["messagesPerSecond"] = options[:messages_per_second]
end
@n_messages_per_second = options[:messages_per_second] || DEFAULT_MESSAGES_PER_SECOND
@n_messages_per_second = [@n_messages_per_second, 1].max

dump_message = {
"type" => "dump",
"dataset" => @dataset,
"body" => dump_params,
"body" => {
"messagesPerSecond" => @n_messages_per_second,
},
}
client.subscribe(dump_message) do |message|
on_progress(message)
Expand Down

0 comments on commit 47ac7ab

Please sign in to comment.