http_health_check 0.3.1 → 0.4.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
  SHA256:
3
- metadata.gz: f139d8fa2b538a20c22d2cf53a84d16a7872cd7f60173c4d78b4142350ae68ee
4
- data.tar.gz: 27d1a8172548424d135124278662ff5558488245adca6361ca1f7c2c53382872
3
+ metadata.gz: 1ae08f694494aa01e0667a635ae85163e9d675da9a8e97bb1ad9194296c113d0
4
+ data.tar.gz: 44b3ae8a18369eaf1da10c9ba7283272a395f2afda8fe6e964cc2fc1643e2bc5
5
5
  SHA512:
6
- metadata.gz: 4b8c69c5d3144a65471c2862c41874773d9ecec184d6ae882605f42411c9c114924bb4c33866f8cf90f168b0d5f6d6492e2c9338a58bf0a370de276c5d11272e
7
- data.tar.gz: eebeab8973c4b956e49f0cc28cb17dc54de82b0f9569cd81508c52e7be5db3c1b3735a23ab1c68b68549ca6ede8cf208ca1cd12c65ddacc476794eb2ccfa5060
6
+ metadata.gz: '069a950fe9727f24980ad7b38014d73369a7963796606c2d3fddfdfa13da3e710776ba24174dfc9d511175a65d05aa40b6b3f5d15aba3c53380f84a088af3309'
7
+ data.tar.gz: b149e9ae46abbcc0131f652135e19aca4e747adaa3f39913457a0e768f38b1b697fd470ffc1bc6e2eee952b847bf8359a1653d699a34f41cf8f0e44c9a76a6fb
data/.bumpversion.cfg CHANGED
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.3.1
2
+ current_version = 0.4.0
3
3
  commit = True
4
4
  tag = True
5
5
  tag_name = {new_version}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG.md
2
2
 
3
+ ## 0.4.0 (2022-07-20)
4
+
5
+ Features:
6
+
7
+ - add karafka consumer groups utility function
8
+
3
9
  ## 0.3.0 (2022-07-19)
4
10
 
5
11
  Features:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- http_health_check (0.3.1)
4
+ http_health_check (0.4.0)
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.1'
14
+ gem 'http_health_check', '~> 0.4.0'
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
@@ -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.1'
4
+ VERSION = '0.4.0'
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.1
4
+ version: 0.4.0
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-07-20 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: