class Hivent::CLI::Consumer
Public Class Methods
new(options)
click to toggle source
# File lib/hivent/cli/consumer.rb, line 17 def initialize(options) @options = options end
run!(args)
click to toggle source
# File lib/hivent/cli/consumer.rb, line 13 def self.run!(args) new(args).run! end
Public Instance Methods
run!()
click to toggle source
# File lib/hivent/cli/consumer.rb, line 21 def run! configure register_service worker_name = "#{Socket.gethostname}:#{Process.pid}" @worker = Hivent::Redis::Consumer.new(@redis, @service_name, worker_name, @life_cycle_event_handler) @worker.run! end
Private Instance Methods
configure()
click to toggle source
# File lib/hivent/cli/consumer.rb, line 33 def configure # use load instead of require to allow multiple runs of this method in specs load @options[:require] @service_name = Hivent::Config.client_id @partition_count = Hivent::Config.partition_count @life_cycle_event_handler = Hivent::Config.life_cycle_event_handler || Hivent::LifeCycleEventHandler.new @events = Hivent.emitter.events @redis = Hivent::Redis.redis end
register_service()
click to toggle source
# File lib/hivent/cli/consumer.rb, line 45 def register_service # TODO: cleanup unused events for this service from the registry @redis.set("#{@service_name}:partition_count", @partition_count) @events.each do |event| @redis.sadd(event[:name], @service_name) end @life_cycle_event_handler.application_registered(@service_name, @events.deep_dup, @partition_count) end