config_skeleton 1.0.0 → 1.1.0

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: 114069700875be6dd679f4731609175447186ddcbde862bdfef1d516c0f66601
4
- data.tar.gz: 424208817f7b1c407272909e8c13e7e9e308dab0ca18e68ce5fda208c9536464
3
+ metadata.gz: 0b419f026421b513b20f2950609f9b45339d86433b88e8372bd94746f6a72091
4
+ data.tar.gz: 7e0a5ac1b0dfe9ad7ee989aeb9d0051b06d179190328460ba09c273312b36b7d
5
5
  SHA512:
6
- metadata.gz: 1da2b1664644625d452e3aa6d7f10435901dd63c1084f1e6d1f9b0ad87e1ffc977efef0e9d64db11ffb072ab495d2a2064ca5b25f1afcc0b27b0ba9750a2d550
7
- data.tar.gz: a288a8a63fba3019181fe44011c21088136e0c89dc72fb7f870dd96ce2fafc2eef599b9eb1a327149ba0ac973d75cbdda3ef3d164345d6984b6e84e14ed550d0
6
+ metadata.gz: c36398b332b1bfa53a66d11a2c083af4a0f794e53fba518278fcef7ef41dfc63d51b4b010f508eeb898bf99c10ff55a2f813251bdfefe122a70e3254b87da46a
7
+ data.tar.gz: 53acc41e5da3aea61cda288cfe90f122e8d8871eea594d5e4b0857d127c01ba20a542df7087884c34e0e75589e968820d53b41db62c3f85f91d49eea9dbf88a2
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "config_skeleton"
3
3
 
4
- s.version = "1.0.0"
4
+ s.version = "1.1.0"
5
5
 
6
6
  s.platform = Gem::Platform::RUBY
7
7
 
@@ -240,11 +240,16 @@ class ConfigSkeleton
240
240
  logger.debug(logloc) { "notifier fd is #{notifier.to_io.inspect}" }
241
241
 
242
242
  loop do
243
- if ios = IO.select(
244
- [notifier.to_io, @terminate_r, @trigger_regen_r],
245
- [], [],
246
- sleep_duration.tap { |d| logger.debug(logloc) { "Sleeping for #{d} seconds" } }
247
- )
243
+ if cooldown_duration > 0
244
+ logger.debug(logloc) { "Sleeping for #{cooldown_duration} seconds (cooldown)" }
245
+ IO.select([@terminate_r], [], [], cooldown_duration)
246
+ end
247
+
248
+ timeout = sleep_duration - cooldown_duration
249
+ logger.debug(logloc) { "Sleeping for #{timeout} seconds unless interrupted" }
250
+ ios = IO.select([notifier.to_io, @terminate_r, @trigger_regen_r], [], [], timeout)
251
+
252
+ if ios
248
253
  if ios.first.include?(notifier.to_io)
249
254
  logger.debug(logloc) { "inotify triggered" }
250
255
  notifier.process
@@ -444,6 +449,21 @@ class ConfigSkeleton
444
449
  60
445
450
  end
446
451
 
452
+ # How long to ignore signals/notifications after a config regeneration
453
+ #
454
+ # Hammering a downstream service with reload requests is often a bad idea.
455
+ # This method exists to allow subclasses to define a 'cooldown' duration.
456
+ # After each config regeneration, the config generator will sleep for this
457
+ # duration, regardless of any CONT signals or inotify events. Those events
458
+ # will be queued up, and processed at the end of the cooldown.
459
+ #
460
+ # @return [Integer] the number of seconds to 'cooldown' for. This *must* be
461
+ # greater than zero, and less than sleep_duration
462
+ #
463
+ def cooldown_duration
464
+ 5
465
+ end
466
+
447
467
  # The instance of INotify::Notifier that is holding our file watches.
448
468
  #
449
469
  # @return [INotify::Notifier]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_skeleton
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-01 00:00:00.000000000 Z
12
+ date: 2021-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: diffy