ntq_tools 0.7.2 → 0.7.4

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: d9a6423facf8642edbfb60c8e40feb6ce68d3ebbdcba52c3677df5e7a154f3ad
4
+ data.tar.gz: b239adf65c0b94498e36a23cbeb13377b2767856352964e216f49d4454f4ef6e
5
5
  SHA512:
6
- metadata.gz: 4a6b23a31814bd31ce80ef72abd9557f81be5eb6ebf6b5aada2ca40e484076ebf070c6bf034f914e583fce9e9df82703a6530692433d0958e94773eb2ea5d0ca
7
- data.tar.gz: fb0594332a15d859e54dd481f5fce2d4d8d5c5f30d5bd662f2c27ca5b13af1d33934d0c1a391034b9090838ed0b14948a0b724a7206259326dcb7d382c6eb514
6
+ metadata.gz: ac007f1cf19c09875bbdebc547ffe9d48e5c73f849771e09232e4ec14a1344e9b23da1dd702898f99c87bc3a35a7570cbee81eb5c0d6929b40d077fe7809902a
7
+ data.tar.gz: d7f97a1da8afbda1ca27d6a2022258c913c59ad5bde214d37ca571458dcf60aab7802735f8bac882ef85a4c0315aa1d1f5134d8fbb7eed319a561cf6cfbc2374
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, container_version: ENV['CONTAINER_VERSION'] }, status: @status == :ok ? :ok : :service_unavailable
13
13
  end
14
14
  format.html do
15
15
  end
@@ -239,7 +239,7 @@ FILE
239
239
  if defined?(Interactor)
240
240
  create_file "app/interactors/#{plural_name}/search_#{plural_name}.rb", <<-FILE
241
241
  module #{context_name}
242
- class Search#{class_name}
242
+ class Search#{plural_name.camelcase}
243
243
  include Interactor::Organizer
244
244
 
245
245
  organize Get#{plural_name.camelcase}, PaginateRecords
@@ -249,7 +249,7 @@ end
249
249
 
250
250
  create_file "app/interactors/#{plural_name}/get_#{plural_name}.rb", <<-FILE
251
251
  module #{context_name}
252
- class Get#{class_name}
252
+ class Get#{plural_name.camelcase}
253
253
  include Interactor
254
254
 
255
255
  def call
@@ -6,4 +6,6 @@ NtqTools.setup do |config|
6
6
  config.impersonation_enabled = true
7
7
  config.impersonation_user_models = ["User"]
8
8
 
9
+ # config.js_model_dir = Rails.root.join("app", "javascript", "react", "hooks")
10
+
9
11
  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.2"
2
+ VERSION = "0.7.4"
3
3
  end
data/lib/ntq_tools.rb CHANGED
@@ -9,8 +9,10 @@ module NtqTools
9
9
  mattr_accessor :impersonation_user_models
10
10
  @@impersonation_user_models = []
11
11
 
12
+ mattr_accessor :js_model_dir
13
+ @@js_model_dir = nil
14
+
12
15
  def self.setup
13
16
  yield self
14
17
  end
15
-
16
18
  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.4
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-07-12 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