lib/contrast/components/contrast_service.rb in contrast-agent-4.8.0 vs lib/contrast/components/contrast_service.rb in contrast-agent-4.9.0
- old
+ new
@@ -11,58 +11,53 @@
# parent_configuration_spec.yaml.
# Specifically, this allows for querying the state of the connection to
# the Service, as well as sending a message to the Service.
class Interface
include Contrast::Components::ComponentBase
- include Contrast::Components::Interface
DEFAULT_SERVICE_LOG = 'contrast_service.log'
# The Rails ActionDispatch regexp for localhost IP + literal localhost
# https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/http/request.rb#L32
LOCALHOST = Regexp.union [/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/, /^::1$/, /^0:0:0:0:0:0:0:1(%.*)?$/, /^localhost$/]
- access_component :agent, :config
-
def use_bundled_service?
# Validates the config to decide if it's suitable for starting
# the bundled service
# Requirement says "must be true" but that
# should be "must not be false" -- oops.
- @_use_bundled_service ||= !false?(CONFIG.root.agent.start_bundled_service) &&
+ @_use_bundled_service ||= !false?(::Contrast::CONFIG.root.agent.start_bundled_service) &&
# Either a valid host or a valid socket
# Path validity is the service's problem
(LOCALHOST.match?(host) || !!socket_path)
end
def host
- @_host ||= (CONFIG.root.agent.service.host || Contrast::Config::ServiceConfiguration::DEFAULT_HOST).to_s
+ @_host ||= (::Contrast::CONFIG.root.agent.service.host || Contrast::Config::ServiceConfiguration::DEFAULT_HOST).to_s
end
def port
- @_port ||= (CONFIG.root.agent.service.port || Contrast::Config::ServiceConfiguration::DEFAULT_PORT).to_i
+ @_port ||= (::Contrast::CONFIG.root.agent.service.port || Contrast::Config::ServiceConfiguration::DEFAULT_PORT).to_i
end
def socket_path
- @_socket_path ||= CONFIG.root.agent.service.socket
+ @_socket_path ||= ::Contrast::CONFIG.root.agent.service.socket
end
def use_tcp?
socket_path.nil?
end
def logger_path
- @_logger_path ||= CONFIG.root.agent.service.logger.path || DEFAULT_SERVICE_LOG
+ @_logger_path ||= ::Contrast::CONFIG.root.agent.service.logger.path || DEFAULT_SERVICE_LOG
end
private
def disabled?
- @_disabled = false?(CONFIG.root.agent.start_bundled_service) if @_disabled.nil?
+ @_disabled = false?(::Contrast::CONFIG.root.agent.start_bundled_service) if @_disabled.nil?
@_disabled
end
end
-
- COMPONENT_INTERFACE = Interface.new
end
end
end