Module: ASIR::Identity

Included in:
Message, Result
Defined in:
lib/asir/identity.rb

Overview

!SLIDE Message Identity

Constant Summary collapse

@@uuid_pid =
nil

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clientObject

Optional: Opaque data about the Client that created the Message.



12
13
14
# File 'lib/asir/identity.rb', line 12

def client
  @client
end

#identifierObject

Returns the value of attribute identifier.



9
10
11
# File 'lib/asir/identity.rb', line 9

def identifier
  @identifier
end

#serverObject

Optional: Opaque data about the Service that handled the Result.



15
16
17
# File 'lib/asir/identity.rb', line 15

def server
  @server
end

#timestampObject

Returns the value of attribute timestamp.



9
10
11
# File 'lib/asir/identity.rb', line 9

def timestamp
  @timestamp
end

Instance Method Details

#create_identifier!Object

Creates a thread-safe unique identifier.



18
19
20
21
22
23
24
25
26
27
# File 'lib/asir/identity.rb', line 18

def create_identifier!
  @identifier ||= 
    @@identifier_mutex.synchronize do
      if @@uuid_pid != $$
        @@uuid_pid = $$
        @@uuid = nil
      end
      "#{@@counter += 1}-#{@@uuid ||= ::ASIR::UUID.generate}".freeze
    end
end

#create_timestamp!Object

Creates a timestamp.



31
32
33
34
# File 'lib/asir/identity.rb', line 31

def create_timestamp!
  @timestamp ||= 
    ::Time.now.gmtime
end