Module: Fluent::UniqueId

Defined in:
lib/fluent/unique_id.rb

Defined Under Namespace

Modules: Mixin

Class Method Summary collapse

Class Method Details

.generateObject



19
20
21
22
23
# File 'lib/fluent/unique_id.rb', line 19

def self.generate
  now = Time.now.utc
  u1 = ((now.to_i * 1000 * 1000 + now.usec) << 12 | rand(0xfff))
  [u1 >> 32, u1 & 0xffffffff, rand(0xffffffff), rand(0xffffffff)].pack('NNNN')
end

.hex(unique_id) ⇒ Object



25
26
27
# File 'lib/fluent/unique_id.rb', line 25

def self.hex(unique_id)
  unique_id.unpack1('H*')
end