http_health_check 0.3.0 → 0.4.1

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: 575cd5eaa80f9a89c3610213e7722f49d8dd05c09a239000129adc3e9eda6977
4
- data.tar.gz: 97867356d935197b51be6ac31f4a6f9bf5b523dea9af82b4fa1915363d0f0dbc
3
+ metadata.gz: dbcda1b1c0dfb9f27c203567ceb3e903904200cf08b6b52cc89af26e34be8ab9
4
+ data.tar.gz: 026fe60fa05456d2cc14551964a2ff4057b010712bfbec84b67c0d171972eb9c
5
5
  SHA512:
6
- metadata.gz: 248742f7916d9a854895b45f761dac4cd6a8f7a47c6419afe844b68ce79e8488cb8ae4beb2f62a711c9b76d723981f1bc33bab46dcecf4e775aa73fa96f33445
7
- data.tar.gz: c5dac68feccacd62728cc5252ac7c8d3dad9ba65cbb064f37e9db4cbce67047a76652d4c479fdeb476e2cedc1230f74fef05345f04c9ad534c9e46c9bba8816c
6
+ metadata.gz: 1f3565af25d600fa7185f2d57d03132f81bc3b80e84f652fcb5c431bdba41eab42df4c1b6912ecacacafcf9d83c8551a67a0f3ab3191ec916563d98ae18e6e88
7
+ data.tar.gz: 49eec7ce633f4f3ef235acc8a23fb71d7029df2212fb9ab6fb4fdf505fa4e9265438089f74d16f22d0dbb88ea70625c771f2bb0929326994c4d337fa25da58fc
data/.bumpversion.cfg CHANGED
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.3.0
2
+ current_version = 0.4.1
3
3
  commit = True
4
4
  tag = True
5
5
  tag_name = {new_version}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # CHANGELOG.md
2
2
 
3
+ ## 0.4.1 (2022-08-05)
4
+
5
+ Fix:
6
+
7
+ - Fix DelayedJob probe [PR#2](https://github.com/SberMarket-Tech/http_health_check/pull/2)
8
+
9
+ ## 0.4.0 (2022-07-20)
10
+
11
+ Features:
12
+
13
+ - add karafka consumer groups utility function
14
+
3
15
  ## 0.3.0 (2022-07-19)
4
16
 
5
17
  Features:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- http_health_check (0.3.0)
4
+ http_health_check (0.4.1)
5
5
  rack (~> 2.0)
6
6
  webrick
7
7
 
@@ -66,6 +66,7 @@ GEM
66
66
  simplecov (~> 0.19)
67
67
  simplecov-html (0.12.3)
68
68
  simplecov_json_formatter (0.1.4)
69
+ thor (1.1.0)
69
70
  thread_safe (0.3.6)
70
71
  tzinfo (1.2.9)
71
72
  thread_safe (~> 0.1)
@@ -88,6 +89,7 @@ DEPENDENCIES
88
89
  rubocop (~> 0.81)
89
90
  simplecov
90
91
  simplecov-cobertura
92
+ thor (>= 0.20)
91
93
 
92
94
  BUNDLED WITH
93
95
  2.3.15
data/README.md CHANGED
@@ -11,7 +11,7 @@ HttpHealthCheck is built with kubernetes health probes in mind, but it can be us
11
11
  Add this line to your application's Gemfile:
12
12
 
13
13
  ```ruby
14
- gem 'http_health_check', '~> 0.3.0'
14
+ gem 'http_health_check', '~> 0.4.1'
15
15
  ```
16
16
 
17
17
  And then execute:
@@ -68,7 +68,7 @@ HttpHealthCheck.run_server_async(
68
68
  port: 5555,
69
69
  rack_app: HttpHealthCheck::RackApp.configure do |c|
70
70
  c.probe '/readiness/karafka', HttpHealthCheck::Probes::RubyKafka.new(
71
- consumer_groups: KarafkaApp.consumer_groups.map(&:id),
71
+ consumer_groups: HttpHealthCheck::Utils::Karafka.consumer_groups(KarafkaApp),
72
72
  # default heartbeat interval is 3 seconds, but we want to give it
73
73
  # an ability to skip a few before failing the probe
74
74
  heartbeat_interval_sec: 10,
@@ -96,7 +96,7 @@ class KarafkaApp < Karafka::App
96
96
  end
97
97
  end
98
98
 
99
- KarafkaApp.consumer_groups.map(&:id)
99
+ HttpHealthCheck::Utils::Karafka.consumer_groups(KarafkaApp)
100
100
  # => ['foo', 'foo']
101
101
  ```
102
102
 
@@ -35,4 +35,5 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency 'redis', '~> 4.2.5'
36
36
  spec.add_development_dependency 'rspec', '~> 3.2'
37
37
  spec.add_development_dependency 'rubocop', '~> 0.81'
38
+ spec.add_development_dependency 'thor', '>= 0.20'
38
39
  end
@@ -17,6 +17,7 @@ module HttpHealthCheck
17
17
  end
18
18
 
19
19
  def probe(_env)
20
+ @delayed_job.where(queue: HealthCheckJob.queue_name).each(&:destroy!)
20
21
  @delayed_job.enqueue(HealthCheckJob).destroy!
21
22
  probe_ok
22
23
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ module HttpHealthCheck
6
+ module Utils
7
+ module Karafka
8
+ # returns a list of consumer groups configured for current process
9
+ #
10
+ # @param karafka_app descendant of Karafka::App
11
+ def self.consumer_groups(karafka_app, program_name: $PROGRAM_NAME, argv: ARGV) # rubocop:disable Metrics/AbcSize
12
+ all_groups = karafka_app.consumer_groups.map(&:id)
13
+ client_id_prefix = karafka_app.config.client_id.gsub('-', '_') + '_'
14
+
15
+ return all_groups if program_name.split('/').last != 'karafka'
16
+ return all_groups if argv[0] != 'server'
17
+
18
+ parsed_option = Thor::Options.new(
19
+ consumer_groups: Thor::Option.new(:consumer_groups, type: :array, default: nil, aliases: :g)
20
+ ).parse(argv).fetch('consumer_groups', []).first.to_s
21
+ return all_groups if parsed_option == ''
22
+
23
+ groups_from_option = parsed_option.split(' ').map { |g| client_id_prefix + g } & all_groups
24
+ groups_from_option.empty? ? all_groups : groups_from_option
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'utils/karafka' if defined?(::Karafka::App)
4
+
5
+ module HttpHealthCheck
6
+ module Utils; end
7
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HttpHealthCheck
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.1'
5
5
  end
@@ -7,6 +7,7 @@ require_relative 'http_health_check/config/dsl'
7
7
  require_relative 'http_health_check/probe'
8
8
  require_relative 'http_health_check/rack_app'
9
9
  require_relative 'http_health_check/probes'
10
+ require_relative 'http_health_check/utils'
10
11
 
11
12
  module HttpHealthCheck
12
13
  class Error < StandardError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_health_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SberMarket team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-19 00:00:00.000000000 Z
11
+ date: 2022-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.81'
111
+ - !ruby/object:Gem::Dependency
112
+ name: thor
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0.20'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0.20'
111
125
  description: Simple and extensible HTTP health checks server.
112
126
  email:
113
127
  - pochi.73@gmail.com
@@ -141,6 +155,8 @@ files:
141
155
  - lib/http_health_check/probes/ruby_kafka.rb
142
156
  - lib/http_health_check/probes/sidekiq.rb
143
157
  - lib/http_health_check/rack_app.rb
158
+ - lib/http_health_check/utils.rb
159
+ - lib/http_health_check/utils/karafka.rb
144
160
  - lib/http_health_check/version.rb
145
161
  homepage: https://github.com/SberMarket-Tech/http_health_check
146
162
  licenses: