Class: OkComputer::ActionMailerCheck

Inherits:
PingCheck show all
Defined in:
lib/ok_computer/built_in_checks/action_mailer_check.rb

Overview

Verifies if the mail server configured for ActionMailer is responding.

Constant Summary

Constants inherited from PingCheck

PingCheck::ConnectionFailed

Constants inherited from Check

Check::CheckNotDefined

Instance Attribute Summary collapse

Attributes inherited from PingCheck

#request_timeout

Attributes inherited from Check

#failure_occurred, #message, #registrant_name, #time

Instance Method Summary collapse

Methods inherited from Check

#<=>, #clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text, #with_benchmarking

Constructor Details

#initialize(klass = ActionMailer::Base, timeout = 5) ⇒ ActionMailerCheck

Returns a new instance of ActionMailerCheck.



7
8
9
10
11
12
13
# File 'lib/ok_computer/built_in_checks/action_mailer_check.rb', line 7

def initialize(klass = ActionMailer::Base, timeout = 5)
  self.klass = klass
  self.timeout = timeout
  host = klass.smtp_settings[:address]
  port = klass.smtp_settings[:port] || 25
  super(host, port, timeout)
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/ok_computer/built_in_checks/action_mailer_check.rb', line 5

def host
  @host
end

#klassObject

Returns the value of attribute klass.



5
6
7
# File 'lib/ok_computer/built_in_checks/action_mailer_check.rb', line 5

def klass
  @klass
end

#portObject

Returns the value of attribute port.



5
6
7
# File 'lib/ok_computer/built_in_checks/action_mailer_check.rb', line 5

def port
  @port
end

#timeoutObject

Returns the value of attribute timeout.



5
6
7
# File 'lib/ok_computer/built_in_checks/action_mailer_check.rb', line 5

def timeout
  @timeout
end

Instance Method Details

#checkObject

Public: Return the status of the check



16
17
18
19
20
21
22
# File 'lib/ok_computer/built_in_checks/action_mailer_check.rb', line 16

def check
  tcp_socket_request
  mark_message "#{klass} check to #{host}:#{port} successful"
rescue => e
  mark_message "#{klass} at #{host}:#{port} is not accepting connections: '#{e}'"
  mark_failure
end