doctor 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 18197643e4b8cd0d0ff9ccafb49e6b2040a6bf59
4
- data.tar.gz: 0a9e698f2b4a8e49713479bd3dcf56e1a8af5cdf
3
+ metadata.gz: 25a482297d4b6c6c5f12486f82d089a2d8a74cc8
4
+ data.tar.gz: d70df0dad716978a8bfbcfde8d6e0be5b20d9e68
5
5
  SHA512:
6
- metadata.gz: daefc650c78da2bcd1f5af3f350edbfe538ae3526fce3af8802fc0388d9d60d436c4bc36d0145c4b59d8848a603381b2f2726eebc8cfba26b651b098f51ff7b9
7
- data.tar.gz: 22794a5e9d90673893481ea5d5da282b40ac64a89824e1b70a8bdb5dd250f577214682ce776cacb1daac5e23ea4cf199646d8006aeafae4700bce067a2429ffe
6
+ metadata.gz: bd87daf8fcf1b5455526aa679e4fa3e3366991b7c747330877f4e98bbff160a6d31629032e3291d023e3e05732896a76783f2bdec2fb631eaddda64421999ac7
7
+ data.tar.gz: 84ce81d31354588361cc12d3af86974c092d1cdd1921933caa292bdc1b1d661b113fe9957c176e7c5efd80eb11818c5c8072b26371cc5df9b5cdf91b8753b7ad
@@ -17,6 +17,7 @@ module Doctor
17
17
  end
18
18
 
19
19
  private
20
+
20
21
  def validate_telnet_connection(url)
21
22
  result = build_result(url)
22
23
 
@@ -48,10 +49,10 @@ module Doctor
48
49
 
49
50
  def execute_telnet(url)
50
51
  Net::Telnet::new(
51
- "Host" => url[:host],
52
- "Port" => url[:port] || DEFAULT_PORT,
53
- "Timeout" => url[:timeout] || DEFAULT_TIMEOUT,
54
- "Waittime" => url[:wait_time] || DEFAULT_WAIT_TIME
52
+ 'Host' => url[:host],
53
+ 'Port' => url[:port] || DEFAULT_PORT,
54
+ 'Timeout' => url[:timeout] || DEFAULT_TIMEOUT,
55
+ 'Waittime' => url[:wait_time] || DEFAULT_WAIT_TIME
55
56
  )
56
57
  end
57
58
  end
@@ -3,7 +3,13 @@ module Doctor
3
3
  def index
4
4
  check_result = HealthCheck.new.perform
5
5
 
6
- status = check_result.has_error? ? :internal_server_error : :ok
6
+ if check_result.has_error?
7
+ errors = check_result.error_messages
8
+ Rails.logger.error(errors)
9
+ status = :internal_server_error
10
+ else
11
+ status = :ok
12
+ end
7
13
 
8
14
  render json: check_result.result, status: status
9
15
  end
@@ -7,16 +7,23 @@ module Doctor
7
7
  result[:databases] = analyze_database
8
8
  result[:hds] = analyse_hds
9
9
 
10
- OpenStruct.new(result: result, has_error?: has_error?(result))
10
+ error_messages = list_all_error_messages(result)
11
+
12
+ OpenStruct.new(
13
+ result: result,
14
+ has_error?: has_error?(result),
15
+ error_messages: error_messages
16
+ )
11
17
  end
12
18
 
13
19
  private
20
+
14
21
  def analyze_telnet
15
22
  process(TelnetAnalyser, Dto::TelnetResultDto)
16
23
  end
17
24
 
18
25
  def analyze_database
19
- process(DatabaseAnalyser, Dto::DatabaseResultDto)
26
+ process(DatabaseAnalyser, Dto::DatabaseResultDto)
20
27
  end
21
28
 
22
29
  def analyse_hds
@@ -35,16 +42,28 @@ module Doctor
35
42
  dto_result
36
43
  end
37
44
 
38
- def has_error?(result_hash)
39
- result_hash.values.each do |result_analyze|
45
+ def has_error?(result) # rubocop:disable Style/PredicateName
46
+ result.values.each do |result_analyze|
40
47
  result_analyze.each do |result|
41
- if !result.status.eql?('ok')
42
- return true
43
- end
48
+ return true unless result.status.eql?('ok')
44
49
  end
45
50
  end
46
51
 
47
52
  false
48
53
  end
54
+
55
+ def list_all_error_messages(result)
56
+ errors = []
57
+
58
+ result.values.each do |result_analyze|
59
+ result_analyze.each do |result|
60
+ next if result.status.eql?('ok')
61
+
62
+ errors << result.error_message
63
+ end
64
+ end
65
+
66
+ errors
67
+ end
49
68
  end
50
69
  end
@@ -2,6 +2,7 @@ module Doctor
2
2
  module Dto
3
3
  class DatabaseResultDto
4
4
  attr_reader :status
5
+ attr_reader :error_message
5
6
 
6
7
  def initialize(data)
7
8
  @status = data[:status]
@@ -2,6 +2,7 @@ module Doctor
2
2
  module Dto
3
3
  class HdResultDto
4
4
  attr_reader :status
5
+ attr_reader :error_message
5
6
 
6
7
  def initialize(data)
7
8
  @name = data[:name]
@@ -2,6 +2,7 @@ module Doctor
2
2
  module Dto
3
3
  class TelnetResultDto
4
4
  attr_reader :status
5
+ attr_reader :error_message
5
6
 
6
7
  def initialize(data)
7
8
  @name = data[:name]
@@ -1,3 +1,3 @@
1
1
  module Doctor
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doctor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - uaiHebert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-29 00:00:00.000000000 Z
11
+ date: 2016-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties