process_settings 0.4.2 → 0.4.3

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: 7b7ba3c70ca8ae92714ae23e909bd39460ceb1fa630e612c1fda2b961c0439cd
4
- data.tar.gz: c0ca81a582174c416839c172bd3799aa2c87defcba628d0ad0448bbe8252e16f
3
+ metadata.gz: a4459a93e4d3b6e0de8b042b3ba4373a8f5013fe80da36177a64c6f6b30045e5
4
+ data.tar.gz: 9f188aea53f82f5c1f8ceb3fe56b94e169d2d9246653ca85a9c71d6f284cdb3b
5
5
  SHA512:
6
- metadata.gz: 31c79e4d2c84845552b5d163c858b36867a1cfc46e9d350cae5e411989a246eb14b785b4ceed4b5b5c5e359ff9a97dbde2aff062cf6926429e15988b378c10aa
7
- data.tar.gz: c5869950ffa244f37e8feb6ff1a0fa815c651c8322e1ac3c518628ade53a9fc078caa827d8b72b59b060fb8e65fd80a4f3cc0cb745612a07aad5a1604794cc25
6
+ metadata.gz: bbea9359182d39bf9181a21316e36eda1574cad6a7ff80ac1536df41013ba1c9dfe4d45d20d4f51f4d91bebf567d1f3a5ad8983df18793f8626dfd03ebbf4f52
7
+ data.tar.gz: 74ae6e764e89824de9775b4840beecd34785540c3c17191d820d8364856d8ecfcbc310e0621907dabe7bd45398ae44b12e592fb2be2fb6f36d30adc3652d7b1e
data/README.md CHANGED
@@ -3,7 +3,7 @@ This gem provides dynamic settings for Ruby processes. The settings are stored i
3
3
  Settings are managed in a git repo, in separate YAML files for each concern (for example, each micro-service). Each YAML file can be targeted based on matching context values (for example, `service_name`).
4
4
 
5
5
 
6
- The context can be either static to the process (for example, `service_name` or `data_center`) or dynamic (for example, the current web request `domain`).
6
+ The context can be either static to the process (for example, `service_name` or `datacenter`) or dynamic (for example, the current web request `domain`).
7
7
 
8
8
  ## Installation
9
9
  To install this gem directly on your machine from rubygems, run the following:
@@ -37,7 +37,7 @@ The monitor should be initialized with static (unchanging) context for your proc
37
37
  ```
38
38
  ProcessSettings::Monitor.static_context = {
39
39
  "service_name" => "frontend",
40
- "data_center" => "AWS-US-EAST-1"
40
+ "datacenter" => "AWS-US-EAST-1"
41
41
  }
42
42
  ```
43
43
  The `static_context` is important because it is used to pre-filter settings for the process.
@@ -143,18 +143,18 @@ To `target` on context values, provide a hash of key-value pairs. All keys must
143
143
  ```
144
144
  target:
145
145
  service_name: frontend
146
- data_center: AWS-US-EAST-1
146
+ datacenter: AWS-US-EAST-1
147
147
  ```
148
- This will be applied in any process that has `service_name == "frontend"` AND is running in `data_center == "AWS-US-EAST-1"`.
148
+ This will be applied in any process that has `service_name == "frontend"` AND is running in `datacenter == "AWS-US-EAST-1"`.
149
149
 
150
150
  ### Multiple Values Are OR'd
151
151
  Values may be set to an array, in which case the key matches if _any_ of the values matches. For example, consider this target hash:
152
152
  ```
153
153
  target:
154
154
  service_name: [frontend, auth]
155
- data_center: AWS-US-EAST-1
155
+ datacenter: AWS-US-EAST-1
156
156
  ```
157
- This will be applied in any process that has (`service_name == "frontend"` OR `service_name == "auth"`) AND `data_center == "AWS-US-EAST-1"`.
157
+ This will be applied in any process that has (`service_name == "frontend"` OR `service_name == "auth"`) AND `datacenter == "AWS-US-EAST-1"`.
158
158
 
159
159
  ### Precedence
160
160
  The settings YAML files are always combined in alphabetical order by file path. Later settings take precedence over the earlier ones.
@@ -62,14 +62,14 @@ flat_services_yml_json_doc.each do |service, nodes|
62
62
  if (changed = node_targeted_process_settings_old != node_targeted_process_settings_new)
63
63
  node_old = node_targeted_process_settings_old.map do |node_targeted_process_setting|
64
64
  {
65
- 'target' => node_targeted_process_setting.target,
66
- "process_settings" => node_targeted_process_setting.process_settings
65
+ 'target' => node_targeted_process_setting.target,
66
+ "settings" => node_targeted_process_setting.settings
67
67
  }
68
68
  end
69
69
  node_new = node_targeted_process_settings_new.map do |node_targeted_process_setting|
70
70
  {
71
- 'target' => node_targeted_process_setting.target,
72
- "process_settings" => node_targeted_process_setting.process_settings
71
+ 'target' => node_targeted_process_setting.target,
72
+ "settings" => node_targeted_process_setting.settings
73
73
  }
74
74
  end
75
75
 
@@ -81,7 +81,7 @@ module ProcessSettings
81
81
  result = statically_targeted_settings.reduce(:not_found) do |latest_result, target_and_settings|
82
82
  # find last value from matching targets
83
83
  if target_and_settings.target.target_key_matches?(full_context)
84
- if (value = target_and_settings.process_settings.json_doc.mine(*path, not_found_value: :not_found)) != :not_found
84
+ if (value = target_and_settings.settings.json_doc.mine(*path, not_found_value: :not_found)) != :not_found
85
85
  latest_result = value
86
86
  end
87
87
  end
@@ -6,7 +6,7 @@ require_relative 'settings'
6
6
  module ProcessSettings
7
7
  # This class encapsulates a single YAML file with target and process_settings.
8
8
  class TargetAndSettings
9
- attr_reader :filename, :target, :process_settings
9
+ attr_reader :filename, :target, :settings
10
10
 
11
11
  def initialize(filename, target, settings)
12
12
  @filename = filename
@@ -15,7 +15,7 @@ module ProcessSettings
15
15
  @target = target
16
16
 
17
17
  settings.is_a?(Settings) or raise ArgumentError, "settings must be a ProcessSettings; got #{settings.inspect}"
18
- @process_settings = settings
18
+ @settings = settings
19
19
  end
20
20
 
21
21
  def ==(rhs)
@@ -29,7 +29,7 @@ module ProcessSettings
29
29
  def to_json_doc
30
30
  {
31
31
  "target" => @target.json_doc,
32
- "settings" => @process_settings.json_doc
32
+ "settings" => @settings.json_doc
33
33
  }
34
34
  end
35
35
 
@@ -37,9 +37,9 @@ module ProcessSettings
37
37
  def from_json_docs(filename, target_json_doc, settings_json_doc)
38
38
  target_json_doc = Target.new(target_json_doc)
39
39
 
40
- process_settings = Settings.new(settings_json_doc)
40
+ settings = Settings.new(settings_json_doc)
41
41
 
42
- new(filename, target_json_doc, process_settings)
42
+ new(filename, target_json_doc, settings)
43
43
  end
44
44
  end
45
45
 
@@ -49,7 +49,7 @@ module ProcessSettings
49
49
  if new_target == @target
50
50
  self
51
51
  else
52
- self.class.new(@filename, new_target, @process_settings)
52
+ self.class.new(@filename, new_target, @settings)
53
53
  end
54
54
  end
55
55
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ProcessSettings
4
- VERSION = '0.4.2'
4
+ VERSION = '0.4.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: process_settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca