I create an application to get some information every second using websockets-rails gem. Right now, it seems that all messages are sent after the method has completed completely.
My websockets controller:
class DbTestsController< WebsocketRails::BaseController
def run_tests_on_all
dbtsch = DbTestsScheduler.new
dbtsch.run(1, 10, message['shard'], :push) do |ops|
send_message 'db_test.run_tests_on_all', ops
Rails.logger.info(ops)
end
end
end
The 'run' method looks like
def run(ecfs, fafs, shard, operation)
st = tep_t = Time.now
while st + fafs.second > Time.now
Octopus.using(shard) do
send(operation)
end
if tep_t + ecfs.second <= Time.now
tep_t = tep_t + 1.second
yield(@ops) if block_given?
@ops = 0
end
end
end
In the console, I see that it Rails.logger.info(ops)displays a message every second, but send_messagesends all 10 results immediately after the method completes.
source
share