Module: Contrast::Api::Decorators::Address::ClassMethods

Includes:
Components::Interface
Defined in:
lib/contrast/api/decorators/address.rb

Overview

Used to add class methods to the ApplicationUpdate class on inclusion of the decorator

Instance Method Summary collapse

Methods included from Components::Interface

included

Instance Method Details

#build_receiverContrast::Api::Dtm::Address

receiver is memoized because it is the address/host/port of the server, once we resolve this for the first time, it shouldn’t change

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/contrast/api/decorators/address.rb', line 28

def build_receiver
  @_build_receiver ||= begin
    address = new
    address.host = 'localhost'
    address.ip = '127.0.0.1'
    begin
      Timeout.timeout(1) do
        address.host = Contrast::Utils::StringUtils.force_utf8(Socket.gethostname)
        address.ip = Contrast::Utils::StringUtils.force_utf8(Resolv.getaddress(address.host))
      end
    rescue StandardError => e
      logger.warn('Unable to resolve host or ip', e, address: address)
    end
    address
  end
end

#build_sender(request) ⇒ Contrast::Api::Dtm::Address

Parse out the sender of the Request and return it as an Address

Returns:



49
50
51
52
53
# File 'lib/contrast/api/decorators/address.rb', line 49

def build_sender request
  sender = new
  sender.ip = Contrast::Utils::StringUtils.force_utf8(request.ip)
  sender
end