ntq_tools 0.7.1 → 0.7.3

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
  SHA256:
3
- metadata.gz: 94c540289f3f6ae2a2c2956b0ee7ee132c57eb7091f36e54350f88cbb86762d2
4
- data.tar.gz: ba67366fe693e767e9a7219b7d9600e03a533d2f1094fa02d3f6b94e532c6393
3
+ metadata.gz: bdfcea4f27002577998567b60bce394305373b5a6bb3a31c9aef29b4f9857abd
4
+ data.tar.gz: 7ae78c43d5f13ab835aa27b9a31f033c484ad44f511a589216d344ee3fe98806
5
5
  SHA512:
6
- metadata.gz: 223b5fda86121d12cdd0c109aaedfb53551dd4d1c5ea584ee13d5b968f62184e50271c43cd5f4acb47aa1872c545e5d640253db1062b1dfe338b412b8d6f4d1f
7
- data.tar.gz: 54addce36763c562fd8a8281edebacb3f5262b0b06bfc4eaaa68321e29e4dd79391f915277a9b42deb72c0a703de0bcbcf29ac5a363119577ffaa465457999a8
6
+ metadata.gz: 9406290d22ab4d908d5f4c6331259039a165c216f97ef393fbdb1ac66f214e9649701937a2618b48de9e932ecb2f713955bf4c0dbb6aca5db18e8e0754e9e04c
7
+ data.tar.gz: 26a4cf2dc0a34406569134364bc5bc8a3b467edf29cddde3c9eea7eebc7bb3bbfc3d63dbf477b88fbb78954cecf688a40a72181be8fc17f619659d2d81f88cf0
data/README.md CHANGED
@@ -12,6 +12,13 @@ MONITORING_PASSWORD
12
12
  MONITORING_USERNAME
13
13
  ```
14
14
 
15
+ Vous pouvez également désactiver certains services manuellement
16
+ ```ruby
17
+ NtqTools::Monitor.configure do |config|
18
+ config.sidekiq = false
19
+ end
20
+ ```
21
+
15
22
  ## Installation
16
23
  Add this line to your application's Gemfile:
17
24
 
@@ -9,7 +9,7 @@ module NtqTools
9
9
 
10
10
  respond_to do |format|
11
11
  format.json do
12
- render json: { status: @status, services_status: @services_status }, status: @status == 'OK' ? :ok : :service_unavailable
12
+ render json: { status: @status, services_status: @services_status }, status: @status == :ok ? :ok : :service_unavailable
13
13
  end
14
14
  format.html do
15
15
  end
@@ -1,10 +1,19 @@
1
1
  require 'ntq_tools/monitors/redis'
2
2
  require 'ntq_tools/monitors/database'
3
3
  require 'ntq_tools/monitors/sidekiq'
4
+ require 'ntq_tools/monitors/configuration'
4
5
 
5
6
  module NtqTools
6
7
  class Monitor
7
8
 
9
+ def self.configure
10
+ yield config
11
+ end
12
+
13
+ def self.config
14
+ @config ||= ::NtqTools::Monitors::Configuration.new
15
+ end
16
+
8
17
  # Check if installed services are running, it return a tuple with the status and the services status
9
18
  #
10
19
  # eg: [:ok, [{name: 'redis', status: 'OK'}, {name: 'database', status: 'OK'}]]
@@ -14,6 +23,8 @@ module NtqTools
14
23
  def self.check
15
24
  services_status = []
16
25
  list.each do |monitor|
26
+ # skip si le service est désactivé (false) dans la config
27
+ next if config.respond_to?(monitor.name) && !config.send(monitor.name)
17
28
  next unless monitor.is_installed?
18
29
 
19
30
  services_status << {
@@ -24,14 +35,14 @@ module NtqTools
24
35
  status = services_status.all? { |service| service[:status] == 'OK' } ? :ok : :error
25
36
  [status, services_status]
26
37
  end
27
-
38
+
28
39
  def self.list
40
+ # ATTENTION - Rajouter le nom du nouveau service (:name) dans la class Configuration (attr_accessor)
29
41
  [
30
42
  ::NtqTools::Monitors::Redis,
31
43
  ::NtqTools::Monitors::Database,
32
44
  ::NtqTools::Monitors::Sidekiq
33
45
  ]
34
46
  end
35
-
36
47
  end
37
- end
48
+ end
@@ -4,7 +4,7 @@ module NtqTools
4
4
  class << self
5
5
 
6
6
  def name
7
- "You must define the name method in your monitor class"
7
+ "You must define the name method in your monitor class and add it to the configuration class"
8
8
  end
9
9
 
10
10
  def is_installed?
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NtqTools
4
+ module Monitors
5
+ class Configuration
6
+ attr_accessor :database, :redis, :sidekiq
7
+
8
+ def initialize
9
+ @database = true
10
+ @redis = true
11
+ @sidekiq = true
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,22 +1,28 @@
1
1
  require 'ntq_tools/monitors/base'
2
+
2
3
  module NtqTools
3
4
  module Monitors
4
5
  class Sidekiq < Base
5
-
6
+
6
7
  class << self
7
8
  def name
8
- "sidekiq"
9
+ 'sidekiq'
9
10
  end
10
-
11
+
11
12
  def is_installed?
12
- ::Gem.loaded_specs.has_key?("sidekiq")
13
+ ::Gem.loaded_specs.has_key?('sidekiq')
13
14
  end
14
-
15
+
15
16
  def check
17
+ require 'sidekiq/api'
16
18
  ::Sidekiq::ProcessSet.new.any? { |process| process['busy'] }
19
+ rescue LoadError
20
+ raise LoadError, <<-ERROR
21
+ ::Sidekiq::ProcessSet could not be loaded by gem ntq_tools.
22
+ It is required for Sidekiq monitoring'
23
+ ERROR
17
24
  end
18
25
  end
19
-
20
26
  end
21
27
  end
22
- end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module NtqTools
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.3"
3
3
  end
data/lib/ntq_tools.rb CHANGED
@@ -12,5 +12,4 @@ module NtqTools
12
12
  def self.setup
13
13
  yield self
14
14
  end
15
-
16
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ntq_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-29 00:00:00.000000000 Z
11
+ date: 2024-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -73,6 +73,7 @@ files:
73
73
  - lib/ntq_tools/engine.rb
74
74
  - lib/ntq_tools/monitor.rb
75
75
  - lib/ntq_tools/monitors/base.rb
76
+ - lib/ntq_tools/monitors/configuration.rb
76
77
  - lib/ntq_tools/monitors/database.rb
77
78
  - lib/ntq_tools/monitors/redis.rb
78
79
  - lib/ntq_tools/monitors/sidekiq.rb