umbrellio-utils 1.4.0 → 1.5.1

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: 4ed0221575b9cfc5c5350ea8eed168a30e9804b943c20fc357c8ee36c963d767
4
- data.tar.gz: 18eb1859efe000d5c5d2bb13b57217a84651f0f824542f49c8093439b49d8141
3
+ metadata.gz: 7cd602271ee79c5ada9955b320e8b8f34a4eeaff2d6c5ceb44a4a3925f1c48c0
4
+ data.tar.gz: 0c0e05b3b6c0fdd8859f9c65ee075cda6d22d8d6c583e2adea45c65b48390b61
5
5
  SHA512:
6
- metadata.gz: 2e4077e807ee85ebc7e4db39f3f3e94ee5b75e94fde085082aadcd3d5422a0827522f00d37022cbb1bf6df71a051d5a1faaad53468870fa189f3f496e17d5531
7
- data.tar.gz: cdd6bce77b7ab07d9ebc975c08551c73f0804540ae9fbff1145965118db40ec0a7f0719b25166ea6e4e5bff2bbc2d01a316b20cfd4a9761074fa9e93bd9d7987
6
+ metadata.gz: 53a57309a2caf8fc51c184223401dd7b0ce285446ce1e633afe159dee813071cd37c1624c4735d2a7f263d113e5c65956b3da0be262d686201c99b12e483be74
7
+ data.tar.gz: 11b10e82bc896b39741a7e35ad2c7a0f46eb70fa83c88975994a7515cc4275efa4c7ee6635037d3bbe991f188a986fdd8d8bd2c23bf55217946cf671d2a775d0
@@ -15,7 +15,7 @@ jobs:
15
15
  strategy:
16
16
  fail-fast: false
17
17
  matrix:
18
- ruby: ["3.0", "3.1", "3.2", "3.3"]
18
+ ruby: ["3.1", "3.2", "3.3"]
19
19
 
20
20
  services:
21
21
  postgres:
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ inherit_gem:
3
3
 
4
4
  AllCops:
5
5
  DisplayCopNames: true
6
- TargetRubyVersion: 3.0
6
+ TargetRubyVersion: 3.1
7
7
  SuggestExtensions: false
8
8
 
9
9
  Naming/MethodParameterName:
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ gem "activesupport"
9
9
  gem "bundler"
10
10
  gem "ci-helper"
11
11
  gem "http"
12
- gem "net-pop", github: "ruby/net-pop" # See https://stackoverflow.com/questions/78617432/strange-bundle-update-issue-disappearing-net-pop-0-1-2-dependency
12
+ gem "net-pop"
13
13
  gem "nokogiri"
14
14
  gem "nori"
15
15
  gem "pg"
data/Gemfile.lock CHANGED
@@ -1,93 +1,82 @@
1
- GIT
2
- remote: https://github.com/ruby/net-pop.git
3
- revision: e8d0afe2773b9eb6a23c39e9e437f6fc0fc7c733
4
- specs:
5
- net-pop (0.1.2)
6
- net-protocol
7
-
8
1
  PATH
9
2
  remote: .
10
3
  specs:
11
- umbrellio-utils (1.4.0)
4
+ umbrellio-utils (1.5.1)
12
5
  memery (~> 1)
13
6
 
14
7
  GEM
15
8
  remote: https://rubygems.org/
16
9
  specs:
17
- actioncable (7.1.3.4)
18
- actionpack (= 7.1.3.4)
19
- activesupport (= 7.1.3.4)
10
+ actioncable (7.2.1)
11
+ actionpack (= 7.2.1)
12
+ activesupport (= 7.2.1)
20
13
  nio4r (~> 2.0)
21
14
  websocket-driver (>= 0.6.1)
22
15
  zeitwerk (~> 2.6)
23
- actionmailbox (7.1.3.4)
24
- actionpack (= 7.1.3.4)
25
- activejob (= 7.1.3.4)
26
- activerecord (= 7.1.3.4)
27
- activestorage (= 7.1.3.4)
28
- activesupport (= 7.1.3.4)
29
- mail (>= 2.7.1)
30
- net-imap
31
- net-pop
32
- net-smtp
33
- actionmailer (7.1.3.4)
34
- actionpack (= 7.1.3.4)
35
- actionview (= 7.1.3.4)
36
- activejob (= 7.1.3.4)
37
- activesupport (= 7.1.3.4)
38
- mail (~> 2.5, >= 2.5.4)
39
- net-imap
40
- net-pop
41
- net-smtp
16
+ actionmailbox (7.2.1)
17
+ actionpack (= 7.2.1)
18
+ activejob (= 7.2.1)
19
+ activerecord (= 7.2.1)
20
+ activestorage (= 7.2.1)
21
+ activesupport (= 7.2.1)
22
+ mail (>= 2.8.0)
23
+ actionmailer (7.2.1)
24
+ actionpack (= 7.2.1)
25
+ actionview (= 7.2.1)
26
+ activejob (= 7.2.1)
27
+ activesupport (= 7.2.1)
28
+ mail (>= 2.8.0)
42
29
  rails-dom-testing (~> 2.2)
43
- actionpack (7.1.3.4)
44
- actionview (= 7.1.3.4)
45
- activesupport (= 7.1.3.4)
30
+ actionpack (7.2.1)
31
+ actionview (= 7.2.1)
32
+ activesupport (= 7.2.1)
46
33
  nokogiri (>= 1.8.5)
47
34
  racc
48
- rack (>= 2.2.4)
35
+ rack (>= 2.2.4, < 3.2)
49
36
  rack-session (>= 1.0.1)
50
37
  rack-test (>= 0.6.3)
51
38
  rails-dom-testing (~> 2.2)
52
39
  rails-html-sanitizer (~> 1.6)
53
- actiontext (7.1.3.4)
54
- actionpack (= 7.1.3.4)
55
- activerecord (= 7.1.3.4)
56
- activestorage (= 7.1.3.4)
57
- activesupport (= 7.1.3.4)
40
+ useragent (~> 0.16)
41
+ actiontext (7.2.1)
42
+ actionpack (= 7.2.1)
43
+ activerecord (= 7.2.1)
44
+ activestorage (= 7.2.1)
45
+ activesupport (= 7.2.1)
58
46
  globalid (>= 0.6.0)
59
47
  nokogiri (>= 1.8.5)
60
- actionview (7.1.3.4)
61
- activesupport (= 7.1.3.4)
48
+ actionview (7.2.1)
49
+ activesupport (= 7.2.1)
62
50
  builder (~> 3.1)
63
51
  erubi (~> 1.11)
64
52
  rails-dom-testing (~> 2.2)
65
53
  rails-html-sanitizer (~> 1.6)
66
- activejob (7.1.3.4)
67
- activesupport (= 7.1.3.4)
54
+ activejob (7.2.1)
55
+ activesupport (= 7.2.1)
68
56
  globalid (>= 0.3.6)
69
- activemodel (7.1.3.4)
70
- activesupport (= 7.1.3.4)
71
- activerecord (7.1.3.4)
72
- activemodel (= 7.1.3.4)
73
- activesupport (= 7.1.3.4)
57
+ activemodel (7.2.1)
58
+ activesupport (= 7.2.1)
59
+ activerecord (7.2.1)
60
+ activemodel (= 7.2.1)
61
+ activesupport (= 7.2.1)
74
62
  timeout (>= 0.4.0)
75
- activestorage (7.1.3.4)
76
- actionpack (= 7.1.3.4)
77
- activejob (= 7.1.3.4)
78
- activerecord (= 7.1.3.4)
79
- activesupport (= 7.1.3.4)
63
+ activestorage (7.2.1)
64
+ actionpack (= 7.2.1)
65
+ activejob (= 7.2.1)
66
+ activerecord (= 7.2.1)
67
+ activesupport (= 7.2.1)
80
68
  marcel (~> 1.0)
81
- activesupport (7.1.3.4)
69
+ activesupport (7.2.1)
82
70
  base64
83
71
  bigdecimal
84
- concurrent-ruby (~> 1.0, >= 1.0.2)
72
+ concurrent-ruby (~> 1.0, >= 1.3.1)
85
73
  connection_pool (>= 2.2.5)
86
74
  drb
87
75
  i18n (>= 1.6, < 2)
76
+ logger (>= 1.4.2)
88
77
  minitest (>= 5.1)
89
- mutex_m
90
- tzinfo (~> 2.0)
78
+ securerandom (>= 0.3)
79
+ tzinfo (~> 2.0, >= 2.0.5)
91
80
  addressable (2.8.7)
92
81
  public_suffix (>= 2.0.2, < 7.0)
93
82
  amazing_print (1.6.0)
@@ -105,12 +94,12 @@ GEM
105
94
  umbrellio-sequel-plugins (~> 0.14)
106
95
  coderay (1.1.3)
107
96
  colorize (1.1.0)
108
- concurrent-ruby (1.3.3)
97
+ concurrent-ruby (1.3.4)
109
98
  connection_pool (2.4.1)
110
99
  crass (1.0.6)
111
100
  date (3.3.4)
112
101
  diff-lcs (1.5.1)
113
- docile (1.4.0)
102
+ docile (1.4.1)
114
103
  domain_name (0.6.20240107)
115
104
  drb (2.2.1)
116
105
  dry-inflector (1.1.0)
@@ -130,22 +119,23 @@ GEM
130
119
  http-cookie (~> 1.0)
131
120
  http-form_data (~> 2.2)
132
121
  llhttp-ffi (~> 0.5.0)
133
- http-cookie (1.0.6)
122
+ http-cookie (1.0.7)
134
123
  domain_name (~> 0.5)
135
124
  http-form_data (2.3.0)
136
125
  i18n (1.14.5)
137
126
  concurrent-ruby (~> 1.0)
138
127
  io-console (0.7.2)
139
- irb (1.13.2)
128
+ irb (1.14.0)
140
129
  rdoc (>= 4.0.0)
141
130
  reline (>= 0.4.2)
142
131
  json (2.7.2)
143
- lamian (1.9.0)
132
+ lamian (1.10.0)
144
133
  rails (>= 4.2)
145
134
  language_server-protocol (3.17.0.3)
146
135
  llhttp-ffi (0.5.0)
147
136
  ffi-compiler (~> 1.0)
148
137
  rake (~> 13.0)
138
+ logger (1.6.1)
149
139
  loofah (2.22.0)
150
140
  crass (~> 1.0.2)
151
141
  nokogiri (>= 1.12.0)
@@ -160,46 +150,47 @@ GEM
160
150
  method_source (1.1.0)
161
151
  mini_mime (1.1.5)
162
152
  mini_portile2 (2.8.7)
163
- minitest (5.24.1)
164
- mutex_m (0.2.0)
165
- net-imap (0.4.14)
153
+ minitest (5.25.1)
154
+ net-imap (0.4.16)
166
155
  date
167
156
  net-protocol
157
+ net-pop (0.1.2)
158
+ net-protocol
168
159
  net-protocol (0.2.2)
169
160
  timeout
170
161
  net-smtp (0.5.0)
171
162
  net-protocol
172
163
  nio4r (2.7.3)
173
- nokogiri (1.16.6)
164
+ nokogiri (1.16.7)
174
165
  mini_portile2 (~> 2.8.2)
175
166
  racc (~> 1.4)
176
- nokogiri (1.16.6-arm64-darwin)
167
+ nokogiri (1.16.7-arm64-darwin)
177
168
  racc (~> 1.4)
178
- nokogiri (1.16.6-x86_64-darwin)
169
+ nokogiri (1.16.7-x86_64-darwin)
179
170
  racc (~> 1.4)
180
- nokogiri (1.16.6-x86_64-linux)
171
+ nokogiri (1.16.7-x86_64-linux)
181
172
  racc (~> 1.4)
182
- nori (2.7.0)
173
+ nori (2.7.1)
183
174
  bigdecimal
184
- parallel (1.25.1)
185
- parser (3.3.3.0)
175
+ parallel (1.26.3)
176
+ parser (3.3.5.0)
186
177
  ast (~> 2.4.1)
187
178
  racc
188
- pg (1.5.6)
179
+ pg (1.5.7)
189
180
  pry (0.14.2)
190
181
  coderay (~> 1.1)
191
182
  method_source (~> 1.0)
192
183
  psych (5.1.2)
193
184
  stringio
194
- public_suffix (6.0.0)
185
+ public_suffix (6.0.1)
195
186
  rabbit_messaging (0.15.0)
196
187
  bunny (~> 2.0)
197
188
  lamian
198
189
  rails (>= 5.2)
199
190
  sneakers (~> 2.0)
200
191
  tainbox
201
- racc (1.8.0)
202
- rack (3.1.6)
192
+ racc (1.8.1)
193
+ rack (3.1.7)
203
194
  rack-session (2.0.0)
204
195
  rack (>= 3.0.0)
205
196
  rack-test (2.1.0)
@@ -207,20 +198,20 @@ GEM
207
198
  rackup (2.1.0)
208
199
  rack (>= 3)
209
200
  webrick (~> 1.8)
210
- rails (7.1.3.4)
211
- actioncable (= 7.1.3.4)
212
- actionmailbox (= 7.1.3.4)
213
- actionmailer (= 7.1.3.4)
214
- actionpack (= 7.1.3.4)
215
- actiontext (= 7.1.3.4)
216
- actionview (= 7.1.3.4)
217
- activejob (= 7.1.3.4)
218
- activemodel (= 7.1.3.4)
219
- activerecord (= 7.1.3.4)
220
- activestorage (= 7.1.3.4)
221
- activesupport (= 7.1.3.4)
201
+ rails (7.2.1)
202
+ actioncable (= 7.2.1)
203
+ actionmailbox (= 7.2.1)
204
+ actionmailer (= 7.2.1)
205
+ actionpack (= 7.2.1)
206
+ actiontext (= 7.2.1)
207
+ actionview (= 7.2.1)
208
+ activejob (= 7.2.1)
209
+ activemodel (= 7.2.1)
210
+ activerecord (= 7.2.1)
211
+ activestorage (= 7.2.1)
212
+ activesupport (= 7.2.1)
222
213
  bundler (>= 1.15.0)
223
- railties (= 7.1.3.4)
214
+ railties (= 7.2.1)
224
215
  rails-dom-testing (2.2.0)
225
216
  activesupport (>= 5.0.0)
226
217
  minitest
@@ -228,10 +219,10 @@ GEM
228
219
  rails-html-sanitizer (1.6.0)
229
220
  loofah (~> 2.21)
230
221
  nokogiri (~> 1.14)
231
- railties (7.1.3.4)
232
- actionpack (= 7.1.3.4)
233
- activesupport (= 7.1.3.4)
234
- irb
222
+ railties (7.2.1)
223
+ actionpack (= 7.2.1)
224
+ activesupport (= 7.2.1)
225
+ irb (~> 1.13)
235
226
  rackup (>= 1.0.0)
236
227
  rake (>= 12.2)
237
228
  thor (~> 1.0, >= 1.2.2)
@@ -242,17 +233,16 @@ GEM
242
233
  rdoc (6.7.0)
243
234
  psych (>= 4.0.0)
244
235
  regexp_parser (2.9.2)
245
- reline (0.5.9)
236
+ reline (0.5.10)
246
237
  io-console (~> 0.5)
247
- rexml (3.3.1)
248
- strscan
238
+ rexml (3.3.7)
249
239
  rspec (3.13.0)
250
240
  rspec-core (~> 3.13.0)
251
241
  rspec-expectations (~> 3.13.0)
252
242
  rspec-mocks (~> 3.13.0)
253
- rspec-core (3.13.0)
243
+ rspec-core (3.13.1)
254
244
  rspec-support (~> 3.13.0)
255
- rspec-expectations (3.13.1)
245
+ rspec-expectations (3.13.2)
256
246
  diff-lcs (>= 1.2.0, < 2.0)
257
247
  rspec-support (~> 3.13.0)
258
248
  rspec-json_matcher (0.2.0)
@@ -273,7 +263,7 @@ GEM
273
263
  rubocop-ast (>= 1.31.1, < 2.0)
274
264
  ruby-progressbar (~> 1.7)
275
265
  unicode-display_width (>= 2.4.0, < 3.0)
276
- rubocop-ast (1.31.3)
266
+ rubocop-ast (1.32.3)
277
267
  parser (>= 3.3.1.0)
278
268
  rubocop-capybara (2.21.0)
279
269
  rubocop (~> 1.41)
@@ -307,10 +297,11 @@ GEM
307
297
  rubocop (~> 1.0)
308
298
  ruby-progressbar (1.13.0)
309
299
  ruby2_keywords (0.0.5)
300
+ securerandom (0.3.1)
310
301
  self_data (1.3.0)
311
- semantic_logger (4.15.0)
302
+ semantic_logger (4.16.0)
312
303
  concurrent-ruby (~> 1.0)
313
- sequel (5.82.0)
304
+ sequel (5.84.0)
314
305
  bigdecimal
315
306
  sequel-batches (2.0.2)
316
307
  sequel
@@ -335,8 +326,6 @@ GEM
335
326
  rbtree
336
327
  set (~> 1.0)
337
328
  stringio (3.1.1)
338
- strscan (3.1.0)
339
- symbiont-ruby (0.7.0)
340
329
  table_sync (6.5.0)
341
330
  memery
342
331
  rabbit_messaging (~> 0.13)
@@ -344,21 +333,21 @@ GEM
344
333
  self_data
345
334
  tainbox (2.1.2)
346
335
  activesupport
347
- thor (1.3.1)
336
+ thor (1.3.2)
348
337
  timecop (0.9.10)
349
338
  timeout (0.4.1)
350
339
  tzinfo (2.0.6)
351
340
  concurrent-ruby (~> 1.0)
352
- umbrellio-sequel-plugins (0.15.0.198)
341
+ umbrellio-sequel-plugins (0.16.0.211)
353
342
  sequel
354
- symbiont-ruby
355
343
  unicode-display_width (2.5.0)
344
+ useragent (0.16.10)
356
345
  webrick (1.8.1)
357
346
  websocket-driver (0.7.6)
358
347
  websocket-extensions (>= 0.1.0)
359
348
  websocket-extensions (0.1.5)
360
- yard (0.9.36)
361
- zeitwerk (2.6.16)
349
+ yard (0.9.37)
350
+ zeitwerk (2.6.18)
362
351
 
363
352
  PLATFORMS
364
353
  arm64-darwin-20
@@ -373,7 +362,7 @@ DEPENDENCIES
373
362
  bundler
374
363
  ci-helper
375
364
  http
376
- net-pop!
365
+ net-pop
377
366
  nokogiri
378
367
  nori
379
368
  pg
@@ -393,4 +382,4 @@ DEPENDENCIES
393
382
  yard
394
383
 
395
384
  BUNDLED WITH
396
- 2.5.14
385
+ 2.5.18
@@ -21,7 +21,7 @@ module UmbrellioUtils
21
21
  def retry_on_unique_violation(
22
22
  times: Float::INFINITY, retry_on_all_constraints: false, checked_constraints: [], &block
23
23
  )
24
- retry_on(Sequel::UniqueConstraintViolation, times: times) do
24
+ retry_on(Sequel::UniqueConstraintViolation, times:) do
25
25
  DB.transaction(savepoint: true, &block)
26
26
  rescue Sequel::UniqueConstraintViolation => e
27
27
  constraint_name = Database.get_violated_constraint_name(e)
@@ -7,8 +7,8 @@ module UmbrellioUtils
7
7
  HandledConstaintError = Class.new(StandardError)
8
8
  InvalidPkError = Class.new(StandardError)
9
9
 
10
- def handle_constraint_error(constraint_name, &block)
11
- DB.transaction(savepoint: true, &block)
10
+ def handle_constraint_error(constraint_name, &)
11
+ DB.transaction(savepoint: true, &)
12
12
  rescue Sequel::UniqueConstraintViolation => e
13
13
  if constraint_name.to_s == get_violated_constraint_name(e)
14
14
  raise HandledConstaintError
@@ -23,7 +23,7 @@ module UmbrellioUtils
23
23
  end
24
24
 
25
25
  def each_record(dataset, primary_key: nil, **options, &block)
26
- primary_key = primary_key_from(dataset, primary_key: primary_key)
26
+ primary_key = primary_key_from(dataset, primary_key:)
27
27
 
28
28
  with_temp_table(dataset, **options) do |ids|
29
29
  rows = ids.map { |id| row(id.is_a?(Hash) ? id.values : [id]) }
@@ -47,11 +47,11 @@ module UmbrellioUtils
47
47
  primary_key: nil,
48
48
  temp_table_name: nil
49
49
  )
50
- primary_key = primary_key_from(dataset, primary_key: primary_key)
50
+ primary_key = primary_key_from(dataset, primary_key:)
51
51
  sleep_interval = sleep_interval_from(sleep)
52
52
 
53
53
  temp_table_name = create_temp_table(
54
- dataset, primary_key: primary_key, temp_table_name: temp_table_name&.to_sym
54
+ dataset, primary_key:, temp_table_name: temp_table_name&.to_sym
55
55
  )
56
56
 
57
57
  pk_set = []
@@ -77,7 +77,7 @@ module UmbrellioUtils
77
77
  temp_table_name ||= :"temp_#{model.table_name}_#{time.to_i}_#{time.nsec}"
78
78
  return temp_table_name if DB.table_exists?(temp_table_name)
79
79
 
80
- primary_key = primary_key_from(dataset, primary_key: primary_key)
80
+ primary_key = primary_key_from(dataset, primary_key:)
81
81
 
82
82
  DB.create_table(temp_table_name, unlogged: true) do
83
83
  primary_key.each do |field|
@@ -58,7 +58,7 @@ module UmbrellioUtils
58
58
  end
59
59
 
60
60
  def to_date_part_string(part)
61
- format("%<part>02d", part: part)
61
+ format("%<part>02d", part:)
62
62
  end
63
63
 
64
64
  #
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UmbrellioUtils::Jobs
4
+ extend self
5
+
6
+ Worker = Struct.new(:name)
7
+ Capsule = Struct.new(:name, :worker, :weight)
8
+ Queue = Struct.new(:name, :capsule, :weight)
9
+ Entry = Struct.new(:capsule, :queues, :concurrency)
10
+
11
+ def workers
12
+ @workers ||= []
13
+ end
14
+
15
+ def capsules
16
+ @capsules ||= []
17
+ end
18
+
19
+ def queues
20
+ @queues ||= []
21
+ end
22
+
23
+ def register_worker(name)
24
+ workers << Worker.new(name)
25
+ end
26
+
27
+ def register_capsule(name, worker: :default, weight: 1)
28
+ workers.find { |x| x.name == worker } or raise "Worker not found: #{worker.inspect}"
29
+ capsules << Capsule.new(name, worker, weight)
30
+ end
31
+
32
+ def register_queue(name, capsule: :default, weight: 1)
33
+ capsules.find { |x| x.name == capsule } or raise "Capsule not found: #{capsule.inspect}"
34
+ queues << Queue.new(name, capsule, weight)
35
+ end
36
+
37
+ def retry_interval(error_count, min_interval:, max_interval:)
38
+ interval = min_interval * (1.3**(error_count - 3))
39
+ interval.clamp(min_interval, max_interval).round
40
+ end
41
+
42
+ def configure_capsules!(config, priority_level:, max_concurrency:)
43
+ entries = capsules_for(priority_level, max_concurrency)
44
+
45
+ unless entries.find { |x| x.capsule == :default }
46
+ entries.last.capsule = :default # Default capsule should always be present in sidekiq
47
+ end
48
+
49
+ entries.each do |entry|
50
+ config.capsule(entry.capsule) do |capsule|
51
+ capsule.queues = entry.queues
52
+ capsule.concurrency = entry.concurrency
53
+ end
54
+ end
55
+ end
56
+
57
+ def capsules_for(worker, max_concurrency)
58
+ capsules = self.capsules.select do |capsule|
59
+ next unless capsule.worker.to_s == worker.underscore.to_s
60
+ next unless queues.any? { |queue| queue.capsule == capsule.name }
61
+ true
62
+ end
63
+
64
+ total_weight = capsules.sum(&:weight)
65
+
66
+ result = capsules.filter_map do |capsule|
67
+ weight_coef = capsule.weight / total_weight.to_f
68
+ concurrency = (max_concurrency * weight_coef).to_i
69
+ concurrency = 1 unless concurrency > 1
70
+ queues =
71
+ self.queues.select { |x| x.capsule == capsule.name }.map { |x| [x.name.to_s, x.weight] }
72
+ Entry.new(capsule.name, queues, concurrency)
73
+ end
74
+
75
+ raise "No queues found for worker #{worker.inspect}" if result.empty?
76
+
77
+ result
78
+ end
79
+
80
+ def validate_queue_name!(queue_name)
81
+ found = queues.any? do |queue|
82
+ queue.name.to_s == queue_name.to_s
83
+ end
84
+
85
+ raise "Unknown queue: #{queue_name.inspect}" unless found
86
+ end
87
+ end
@@ -13,7 +13,7 @@ module UmbrellioUtils
13
13
  TableSync::Publishing::Batch.new(
14
14
  object_class: model_class,
15
15
  original_attributes: batch_for_sync.map(&:values),
16
- routing_key: routing_key,
16
+ routing_key:,
17
17
  ).publish_now
18
18
 
19
19
  sleep delay
@@ -20,7 +20,7 @@ module UmbrellioUtils
20
20
  xml.remove_namespaces!
21
21
  xml.xpath("//@*").remove if remove_attributes
22
22
 
23
- tags_converter = snakecase ? -> (tag) { tag.snakecase.to_sym } : -> (tag) { tag.to_sym }
23
+ tags_converter = snakecase ? -> (tag) { snakecase(tag).to_sym } : -> (tag) { tag.to_sym }
24
24
  nori = Nori.new(convert_tags_to: tags_converter, convert_dashes_to_underscores: false)
25
25
  nori.parse(xml.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION))
26
26
  end
@@ -72,5 +72,19 @@ module UmbrellioUtils
72
72
 
73
73
  phone.sanitized
74
74
  end
75
+
76
+ private
77
+
78
+ # See https://github.com/savonrb/nori/blob/main/lib/nori/string_utils.rb
79
+ def snakecase(string)
80
+ str = string.dup
81
+ str.gsub!("::", "/")
82
+ str.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
83
+ str.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
84
+ str.tr!(".", "_")
85
+ str.tr!("-", "_")
86
+ str.downcase!
87
+ str
88
+ end
75
89
  end
76
90
  end
@@ -22,7 +22,7 @@ module UmbrellioUtils
22
22
  def write_to_kv(engine_path:, secret_path:, data:)
23
23
  full_data_path = File.join(engine_path, "data", secret_path)
24
24
  full_meta_path = File.join(engine_path, "metadata", secret_path)
25
- ::Vault.logical.write(full_data_path, data: data)
25
+ ::Vault.logical.write(full_data_path, data:)
26
26
  ::Vault.logical.write(full_meta_path, id: secret_path, max_versions: 1, cas_required: false)
27
27
  end
28
28
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UmbrellioUtils
4
- VERSION = "1.4.0"
4
+ VERSION = "1.5.1"
5
5
  end
@@ -41,8 +41,8 @@ module UmbrellioUtils
41
41
  }
42
42
  end
43
43
 
44
- def synchronize(&block)
45
- GLOBAL_MUTEX.owned? ? yield : GLOBAL_MUTEX.synchronize(&block)
44
+ def synchronize(&)
45
+ GLOBAL_MUTEX.owned? ? yield : GLOBAL_MUTEX.synchronize(&)
46
46
  end
47
47
  end
48
48
 
@@ -53,6 +53,7 @@ require_relative "umbrellio_utils/control"
53
53
  require_relative "umbrellio_utils/database"
54
54
  require_relative "umbrellio_utils/formatting"
55
55
  require_relative "umbrellio_utils/http_client"
56
+ require_relative "umbrellio_utils/jobs"
56
57
  require_relative "umbrellio_utils/misc"
57
58
  require_relative "umbrellio_utils/parsing"
58
59
  require_relative "umbrellio_utils/passwords"
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "UmbrellioUtils is collection of utility classes and helpers"
13
13
  spec.homepage = "https://github.com/umbrellio/utils"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/umbrellio/utils"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umbrellio-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Umbrellio
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-03 00:00:00.000000000 Z
11
+ date: 2024-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: memery
@@ -52,6 +52,7 @@ files:
52
52
  - lib/umbrellio_utils/database.rb
53
53
  - lib/umbrellio_utils/formatting.rb
54
54
  - lib/umbrellio_utils/http_client.rb
55
+ - lib/umbrellio_utils/jobs.rb
55
56
  - lib/umbrellio_utils/misc.rb
56
57
  - lib/umbrellio_utils/parsing.rb
57
58
  - lib/umbrellio_utils/passwords.rb
@@ -79,14 +80,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
80
  requirements:
80
81
  - - ">="
81
82
  - !ruby/object:Gem::Version
82
- version: 3.0.0
83
+ version: 3.1.0
83
84
  required_rubygems_version: !ruby/object:Gem::Requirement
84
85
  requirements:
85
86
  - - ">="
86
87
  - !ruby/object:Gem::Version
87
88
  version: '0'
88
89
  requirements: []
89
- rubygems_version: 3.5.11
90
+ rubygems_version: 3.5.21
90
91
  signing_key:
91
92
  specification_version: 4
92
93
  summary: A set of utilities that speed up development