ntq_tools 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a10636cbd4c36ced30ad1daec3f419db31f45b3fd2bcd611915cdd152ef7d82
4
- data.tar.gz: 8b86aa7e4770082b4a755cff97eab88de26cc6b7478b510c04d630050a8b2758
3
+ metadata.gz: bdfcea4f27002577998567b60bce394305373b5a6bb3a31c9aef29b4f9857abd
4
+ data.tar.gz: 7ae78c43d5f13ab835aa27b9a31f033c484ad44f511a589216d344ee3fe98806
5
5
  SHA512:
6
- metadata.gz: 4a6b23a31814bd31ce80ef72abd9557f81be5eb6ebf6b5aada2ca40e484076ebf070c6bf034f914e583fce9e9df82703a6530692433d0958e94773eb2ea5d0ca
7
- data.tar.gz: fb0594332a15d859e54dd481f5fce2d4d8d5c5f30d5bd662f2c27ca5b13af1d33934d0c1a391034b9090838ed0b14948a0b724a7206259326dcb7d382c6eb514
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
 
@@ -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.2"
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.2
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