config_skeleton 0.3.0 → 0.3.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: bdaa156de0445e8a32b2d49d55ea11308d153d4c73658f6c4ff648a7c32a1440
4
- data.tar.gz: 5dff0715f11dad930b6dd485204d9a1f2b75a47afc9096cb33dd0c4f5a538423
3
+ metadata.gz: 6a58d74e2627a2f4f0ac79fa05c9ce07d2b17b8500af7e38d59fd7a33ac22fe7
4
+ data.tar.gz: 8b1d8531cc3fcc1183d14c465b886833b97130326d891b9da00ef05780b36a2c
5
5
  SHA512:
6
- metadata.gz: e5c7ffc7621e69441f17349d9e46a9d4f5146ed88a4c5b382524dfd64b7c0aa6b4aedc72bcb3ffac220509299983adff24263f86e8a327072ed34b933095ab3e
7
- data.tar.gz: 50e06b7b3fbe40c4baf522b95595bd447ec3e349c2e14a1cbf7da64500f2db5a64d006ec6b9f15a2320fdbc76f879f733d91ff555c26d7eef7432d1fc46ff059
6
+ metadata.gz: 351a846e41802b033bb217d3a574a5a8a18633cc51845313d15ef41220c036a92d068a6959fde5eea4fb25b8586974baf6e02ea62369342d911de5023bcc0863
7
+ data.tar.gz: ebbf67d572a03b463b40e0e359446fd1e76d64ad4a0200556ffb78a425130aebf0876c23b0090e9770c9b6921a0e370d22d9e11520ad875b12b59d95671d4e2b
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "config_skeleton"
3
3
 
4
- s.version = "0.3.0"
4
+ s.version = "0.3.1"
5
5
 
6
6
  s.platform = Gem::Platform::RUBY
7
7
 
@@ -23,7 +23,8 @@ require 'tempfile'
23
23
  #
24
24
  # 1. Implement service-specific config generation and reloading code, by
25
25
  # overriding the private methods #config_file, #config_data, and #reload_server
26
- # (and also potentially #config_ok? and #sleep_duration).
26
+ # (and also potentially #config_ok?, #sleep_duration, #before_regenerate_config, and
27
+ # #after_regenerate_config).
27
28
  # See the documentation for those methods for what they need to do.
28
29
  #
29
30
  # 1. Setup any file watchers you want with .watch and #watch.
@@ -362,6 +363,20 @@ class ConfigSkeleton < ServiceSkeleton
362
363
  raise NotImplementedError, "config_data must be implemented in subclass."
363
364
  end
364
365
 
366
+ # Run code before the config is regenerated and the config_file
367
+ # is written.
368
+ #
369
+ # @note this can optionally be implemented by subclasses.
370
+ #
371
+ def before_regenerate_config(force_reload); end
372
+
373
+ # Run code after the config is regenerated and if the regeneration
374
+ # was forced the new config has been cycled in.
375
+ #
376
+ # @note this can optionally be implemented by subclasses.
377
+ #
378
+ def after_regenerate_config(force_reload); end
379
+
365
380
  # Verify that the currently running config is acceptable.
366
381
  #
367
382
  # In the event that a generated config is "bad", it may be possible to detect
@@ -443,6 +458,8 @@ class ConfigSkeleton < ServiceSkeleton
443
458
  # @return [void]
444
459
  #
445
460
  def regenerate_config(force_reload: false)
461
+ before_regenerate_config(force_reload)
462
+
446
463
  logger.debug(logloc) { "force? #{force_reload.inspect}" }
447
464
  tmpfile = Tempfile.new(service_name, File.dirname(config_file))
448
465
  logger.debug(logloc) { "Tempfile is #{tmpfile.path}" }
@@ -466,6 +483,8 @@ class ConfigSkeleton < ServiceSkeleton
466
483
  cycle_config(tmpfile.path)
467
484
  end
468
485
  end
486
+
487
+ after_regenerate_config(force_reload)
469
488
  ensure
470
489
  metrics.last_change_timestamp.set({}, File.stat(config_file).mtime.to_f)
471
490
  tmpfile.close rescue nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_skeleton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Palmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-26 00:00:00.000000000 Z
11
+ date: 2020-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diffy