Class: Nsqcd::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/nsqcd/support/utils.rb

Class Method Summary collapse

Class Method Details

.make_worker_id(namespace) ⇒ Object



2
3
4
# File 'lib/nsqcd/support/utils.rb', line 2

def self.make_worker_id(namespace)
  "worker-#{namespace}:#{'1'}:#{rand(36**6).floor.to_s(36)}"  # jid, worker id. include date.
end

.parse_workers(workerstring) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/nsqcd/support/utils.rb', line 5

def self.parse_workers(workerstring)
  missing_workers = []
  workers = (workerstring || '').split(',').map do |k|
    begin
      w = Kernel.const_get(k)
    rescue
      missing_workers << k
    end
    w
  end.compact

  [workers, missing_workers]
end