Module: ProcessBalancer::Util

Included in:
CLI, Manager, Watcher
Defined in:
lib/process_balancer/util.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#hostnameObject



11
12
13
# File 'lib/process_balancer/util.rb', line 11

def hostname
  ProcessBalancer.hostname
end

#identityObject



15
16
17
# File 'lib/process_balancer/util.rb', line 15

def identity
  ProcessBalancer.identity
end

#loggerObject



7
8
9
# File 'lib/process_balancer/util.rb', line 7

def logger
  ProcessBalancer.logger
end

#redis(&block) ⇒ Object



19
20
21
# File 'lib/process_balancer/util.rb', line 19

def redis(&block)
  ProcessBalancer.redis(&block)
end

#start_thread(name, &block) ⇒ Object



23
24
25
26
27
28
# File 'lib/process_balancer/util.rb', line 23

def start_thread(name, &block)
  Thread.new do
    Thread.current.name = name
    watchdog(&block)
  end
end

#watchdogObject



30
31
32
33
34
35
# File 'lib/process_balancer/util.rb', line 30

def watchdog
  yield
rescue Exception => e # rubocop: disable Lint/RescueException
  logger.error("#{Thread.current.name} :: #{e.message}")
  raise e
end