blue_green_workers 0.1.0 → 0.2.0
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 +4 -4
- data/README.md +6 -2
- data/lib/blue_green_workers.rb +2 -1
- data/lib/blue_green_workers/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bb20f810be71613d35898d0ec1998b6060a3594
|
4
|
+
data.tar.gz: 148fd9daf814872e616b5baddf9830bf98a3e033
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/lib/blue_green_workers.rb
CHANGED
@@ -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
|
|