configure_semian 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: d47a27158e20da560941a9b5dd4757d8dc2b03c3
4
- data.tar.gz: 07eb8ca0eb264e72938a9f00f663feaaba823547
3
+ metadata.gz: 400c1cccea675b1e1798d2ffcad5e4f8f0fa598f
4
+ data.tar.gz: c7964dd582bed6c40ecd0f2d4fd66c6a69e3d647
5
5
  SHA512:
6
- metadata.gz: 004c300a99db4a8050948bec7a597d2ed3a180489af2407854d46ce9c0e563d17559016902f9d0787e512b32910b798f150881c526aa31c5866c4490d21d9776
7
- data.tar.gz: b356ea59cf6eef8b66599bf8565f41e7a2025aff2f6d1614ccdac4681cc6bf74ee1076f4d5601b247a21ea8a5c34f9694df732d93dbac9f2d9ebf50bca21ef46
6
+ metadata.gz: a3314cb2535401b8460df7f8c3ccfe275326ee69161330e0019d91c23232c56768bc6f248b3da6372046e826473d49ef17111530e44a7ba1f44374540fb02178
7
+ data.tar.gz: e361454eeca1dc89eae75277a2d31044e4b8b00e9be271b81fb8f35e232b045e68747b9b514cb7a17c9266dc625836a137734fe005ffbe33144ceed45cb45670
data/README.md CHANGED
@@ -74,6 +74,25 @@ and for the path '/example/index', the read timeout will be 20s.
74
74
  Note: Only read timeout can be configures at path level, all the other parameters are same as that of its host's.
75
75
  A suggested way to define the service_configs hash would be to define a yml file, and load that file while configuring.
76
76
 
77
+ Update 0.1.2:
78
+ Now added the option to provide different configurations for non-app servers of the service. Following the same structure for the service configs hash, just provide values for the non-app servers under the key :worker. In case values are not defined for non-app servers, gem default values will be used.
79
+ Updated service_configs hash would be:
80
+
81
+ {
82
+ default: {quota: 0.5, timeout: 16},
83
+ 'host.example.com': {
84
+ default: {timeout: 10, bulkhead: false},
85
+ '/example/index': {timeout: 20}
86
+ },
87
+ worker: {
88
+ default: {quota: 0.8, timeout: 20},
89
+ 'host.example.com': {
90
+ default: {timeout: 10, bulkhead: false},
91
+ '/example/index': {timeout: 25}
92
+ }
93
+ }
94
+ }
95
+
77
96
  ## Development
78
97
 
79
98
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -22,7 +22,7 @@ module ConfigureSemian
22
22
 
23
23
  def initialize
24
24
  @app_server = false
25
- @service_configs = SEMIAN_PARAMETERS.with_indifferent_access
25
+ @service_configs = {}
26
26
  @free_hosts = []
27
27
  @track_exceptions = []
28
28
  @service_name = nil
@@ -31,13 +31,11 @@ module ConfigureSemian
31
31
  # Passed true only for app server so that bulkheading is disabled in worker servers
32
32
  def app_server=value
33
33
  @app_server = value
34
- self.service_configs[:semian_default][:bulkhead] = (value || false)
35
34
  end
36
35
 
37
36
  # semian options alongwith the ones defined by the service
38
37
  def service_configs=value
39
- value.with_indifferent_access
40
- self.service_configs.merge!(value)
38
+ @service_configs = value.with_indifferent_access
41
39
  end
42
40
 
43
41
  # exceptions to be tracked defined by the service
@@ -50,7 +48,9 @@ module ConfigureSemian
50
48
  # Define exceptions to be tracked by Semian
51
49
  Semian::NetHTTP.exceptions |= self.track_exceptions
52
50
  # Create the complete host,path driven semian options
53
- semian_default = self.service_configs.delete(:semian_default)
51
+ semian_default = SEMIAN_PARAMETERS[:semian_default].with_indifferent_access
52
+ semian_default[:bulkhead] = self.app_server || false
53
+ choose_configs_for_given_server
54
54
  service_default = semian_default.merge(self.service_configs.delete(:default) || {})
55
55
  service_default.delete(:quota) if !service_default[:tickets].nil?
56
56
  self.service_configs.each do |host, specs|
@@ -64,6 +64,15 @@ module ConfigureSemian
64
64
  self.service_configs.merge!({semian_default: semian_default, default: service_default})
65
65
  end
66
66
 
67
+ # Overriding specifications for nonapp server
68
+ def choose_configs_for_given_server
69
+ if self.app_server
70
+ self.service_configs.delete(:worker)
71
+ else
72
+ self.service_configs = self.service_configs[:worker] || {}
73
+ end
74
+ end
75
+
67
76
  end
68
77
 
69
78
  @@semian_parameters = SemianParameters.new
@@ -1,3 +1,3 @@
1
1
  module ConfigureSemian
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configure_semian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - supantha
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-03 00:00:00.000000000 Z
11
+ date: 2019-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails