blue_green_workers 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: 763c209e7bb28f7c8e3753cc57d4f3e9d0b1c021
4
- data.tar.gz: 1afcd620a1b05e054f56300f0dbdecd0d7509c50
3
+ metadata.gz: 9bb20f810be71613d35898d0ec1998b6060a3594
4
+ data.tar.gz: 148fd9daf814872e616b5baddf9830bf98a3e033
5
5
  SHA512:
6
- metadata.gz: fc6b12114e9d32012f262e85fc34f87bb073edfad3ac36d7c846348b7c483db0a22300bdfc407b64c88a3ae74293caf106cac54860605f9800be86bb201cf620
7
- data.tar.gz: fd9be9b4151d112db6af2eaffb8d4cacf25e1382f86c8c205dc77f0f2c7a1d77639a10ecca8762db659720ea6f72d80198e49b24c3fdfbad04d4ec622747765f
6
+ metadata.gz: 91db6ce2cf44a74f1385cbd5c768a6512879613de21bd6ee760e8b000356831beb028b9bbae12aeac7ba31a243f2a6b1482b683ff112a343b817f4d8a9f2be53
7
+ data.tar.gz: 1c5a2b5a1a89a0d84351c0470c65319becc7f6bfaf41142bb878c678d6b40f7035bc4a448b6bf3a059076320c5ca02209bb6fba9838480eafbaaf80c145b67a6
data/README.md CHANGED
@@ -25,6 +25,7 @@ This gem doesn't attempt to provide an interface through which you specify which
25
25
  BlueGreenWorkers.configure do |config|
26
26
  config.cluster_name = 'blue'
27
27
  config.determine_active_cluster { ActiveCluster.first.value }
28
+ config.refresh_interval = 10
28
29
  config.activate { QueueClient.listen! }
29
30
  config.deactivate { QueueClient.shutdown! }
30
31
  config.logger = Logger.new STDOUT
@@ -33,7 +34,7 @@ end
33
34
 
34
35
  * `cluster_name` - Defines the name for this cluster. Something like `ENV['CLUSTER_NAME']` probably makes sense
35
36
  * `determine_active_cluster` - Takes a block that returns the name of the current active cluster
36
- * `refresh_interval` (optional) - How often to cache the active cluster, `0` (the default) will call the block passed to `determine_active_cluster` every time a worker is executed.
37
+ * `refresh_interval` (optional) - How often to cache the active cluster in seconds, `0` (the default) will call the block passed to `determine_active_cluster` every time a worker is executed.
37
38
  * `activate` (optiona) - Block to call when this cluster goes active. Will be called during initialization. `refresh_interval` must be specified.
38
39
  * `deactivate` (optiona) - Block to call when this cluster goes passive. This block will not be called if the cluster is started in passive mode. `refresh_interval` must be specified.
39
40
  * `logger` (optiona) - Logger to use
@@ -44,13 +45,16 @@ In addition to attaching event handles to `activate` and `deactivate` you can al
44
45
 
45
46
  ```ruby
46
47
  loop do
47
- BlueGreenWorkers.execute do
48
+ BlueGreenWorkers.execute(opts) do
48
49
  # Do some work, poll for stuff, etc
49
50
  end
50
51
  sleep 60
51
52
  end
52
53
  ```
53
54
 
55
+ Options include*
56
+ `delay` -- Delay for `n` seconds if we're not the active cluster
57
+
54
58
  ## Development
55
59
 
56
60
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -21,11 +21,12 @@ module BlueGreenWorkers
21
21
  config.validate
22
22
  end
23
23
 
24
- def self.execute
24
+ def self.execute(opts = {})
25
25
  if config.active_cluster_block.call == config.cluster_name
26
26
  yield
27
27
  else
28
28
  logger.debug 'Workers not active, skipping BlueGreenWorkers#execute'
29
+ opts[:delay] && sleep(opts[:delay])
29
30
  end
30
31
  end
31
32
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BlueGreenWorkers
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blue_green_workers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hawknewton