Class: Drnbench::PublishSubscribe::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/drnbench/publish-subscribe/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Runner

Returns a new instance of Runner.



24
25
26
27
# File 'lib/drnbench/publish-subscribe/runner.rb', line 24

def initialize(config)
  @config = config
  @published_messages = Queue.new
end

Instance Method Details

#increase_subscribersObject



51
52
53
54
55
56
57
58
59
# File 'lib/drnbench/publish-subscribe/runner.rb', line 51

def increase_subscribers
  if @subscribers.empty?
    new_n_subscribers = @config.start_n_subscribers
  else
    new_n_subscribers = @subscribers.size
  end
  add_subscribers(new_n_subscribers)
  ensure_subscribers_ready
end

#n_subscribersObject



29
30
31
# File 'lib/drnbench/publish-subscribe/runner.rb', line 29

def n_subscribers
  @subscribers.size
end

#runObject



43
44
45
46
47
48
49
# File 'lib/drnbench/publish-subscribe/runner.rb', line 43

def run
  publishing_times = @config.n_publishings
  n_will_be_published_messages = @subscribers.size * publishing_times

  do_feed(publishing_times)
  receive_messages(n_will_be_published_messages)
end

#setupObject



33
34
35
36
# File 'lib/drnbench/publish-subscribe/runner.rb', line 33

def setup
  setup_server
  setup_subscribers
end

#teardownObject



38
39
40
41
# File 'lib/drnbench/publish-subscribe/runner.rb', line 38

def teardown
  teardown_subscribers
  teardown_server
end