Module: Plezi::Base::Identification

Defined in:
lib/plezi/controller/identification.rb

Class Method Summary collapse

Class Method Details

.pidObject

returns a Plezi flavored pid UUID, used to set the pub/sub channel when scaling



9
10
11
12
13
14
15
16
# File 'lib/plezi/controller/identification.rb', line 9

def pid
   process_pid = ::Process.pid
   if @ppid != process_pid
      @pid = nil
      @ppid = process_pid
   end
   @pid ||= SecureRandom.urlsafe_base64.tap { |str| @prefix_len = str.length }
end

.target2pid(target) ⇒ Object

Extracts the machine part from a target’s Global UUID



24
25
26
# File 'lib/plezi/controller/identification.rb', line 24

def target2pid(target)
   target ? target[0..(@prefix_len - 1)] : Plezi.app_name
end

.target2uuid(target) ⇒ Object

Converts a target Global UUID to a localized UUID



18
19
20
21
# File 'lib/plezi/controller/identification.rb', line 18

def target2uuid(target)
   return nil unless target.start_with? pid
   target[@prefix_len..-1].to_i
end