queue-bus 0.13.0 → 0.13.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 +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/queue_bus/dispatch.rb +9 -3
- data/lib/queue_bus/version.rb +1 -1
- data/spec/dispatch_spec.rb +17 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5383fd5290386ad57b383532a59406032e960ee344dc218db4c6c2e83a8fc8df
|
4
|
+
data.tar.gz: 6e695fc97a76265c6fa98984278e517b5e21dc7142c7d7b9ff646e02e52af5ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a238383614d2505facac1c2003d8b55cff3d3c68c1bd0a136ce5444cbae92377df9fd9316feb912180bc2a9272f30257dcc028c345178cc56c18f6c9fee8aa5
|
7
|
+
data.tar.gz: 507b3514db5c2290e4c2cedf60d77cfed61f8fc9b4b0ae1c647de40350fdd52342144b4bdba32ad94fc5f734fd4413d80f7517ff083ebda0d8f1b28984c28421
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.13.1]
|
10
|
+
|
11
|
+
### Fixes
|
12
|
+
|
13
|
+
- Allows matching on 0 via the `on_heartbeat` subscription
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
- Allows matching on `wday` via the `on_heartbeat` subscription
|
18
|
+
|
9
19
|
## [0.13.0]
|
10
20
|
|
11
21
|
### Added
|
data/lib/queue_bus/dispatch.rb
CHANGED
@@ -16,7 +16,7 @@ module QueueBus
|
|
16
16
|
@subscriptions.size
|
17
17
|
end
|
18
18
|
|
19
|
-
def on_heartbeat(key, minute: nil, hour: nil, minute_interval: nil, hour_interval: nil, &block) # rubocop:disable Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/ParameterLists, Metrics/CyclomaticComplexity, Metrics/AbcSize
|
19
|
+
def on_heartbeat(key, minute: nil, hour: nil, wday: nil, minute_interval: nil, hour_interval: nil, &block) # rubocop:disable Metrics/PerceivedComplexity, Metrics/MethodLength, Metrics/ParameterLists, Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/LineLength
|
20
20
|
if minute_interval && !minute_interval.positive?
|
21
21
|
raise ArgumentError, 'minute_interval must be a positive integer'
|
22
22
|
end
|
@@ -28,17 +28,23 @@ module QueueBus
|
|
28
28
|
matcher = { bus_event_type: :heartbeat_minutes }
|
29
29
|
|
30
30
|
if minute
|
31
|
-
raise ArgumentError, 'minute must be
|
31
|
+
raise ArgumentError, 'minute must not be negative' if minute.negative?
|
32
32
|
|
33
33
|
matcher['minute'] = minute
|
34
34
|
end
|
35
35
|
|
36
36
|
if hour
|
37
|
-
raise ArgumentError, 'hour must be
|
37
|
+
raise ArgumentError, 'hour must not be negative' if hour.negative?
|
38
38
|
|
39
39
|
matcher['hour'] = hour
|
40
40
|
end
|
41
41
|
|
42
|
+
if wday
|
43
|
+
raise ArgumentError, 'wday must not be negative' if wday.negative?
|
44
|
+
|
45
|
+
matcher['wday'] = wday
|
46
|
+
end
|
47
|
+
|
42
48
|
subscribe(key, matcher) do |event|
|
43
49
|
if (minute_interval.nil? || (event['minute'] % minute_interval).zero?) &&
|
44
50
|
(hour_interval.nil? || (event['hour'] % hour_interval).zero?)
|
data/lib/queue_bus/version.rb
CHANGED
data/spec/dispatch_spec.rb
CHANGED
@@ -61,7 +61,8 @@ module QueueBus
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'subscribes to hour 8' do
|
64
|
-
expect(dispatch.subscriptions.all.first.matcher.filters)
|
64
|
+
expect(dispatch.subscriptions.all.first.matcher.filters)
|
65
|
+
.to eq('bus_event_type' => 'heartbeat_minutes', 'hour' => '8')
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
@@ -73,7 +74,8 @@ module QueueBus
|
|
73
74
|
end
|
74
75
|
|
75
76
|
it 'subscribes to minute 4' do
|
76
|
-
expect(dispatch.subscriptions.all.first.matcher.filters)
|
77
|
+
expect(dispatch.subscriptions.all.first.matcher.filters)
|
78
|
+
.to eq('bus_event_type' => 'heartbeat_minutes', 'minute' => '4')
|
77
79
|
end
|
78
80
|
end
|
79
81
|
|
@@ -90,6 +92,19 @@ module QueueBus
|
|
90
92
|
end
|
91
93
|
end
|
92
94
|
|
95
|
+
context 'when running on wday 2' do
|
96
|
+
before do
|
97
|
+
dispatch.on_heartbeat event_name, wday: 2 do |_event|
|
98
|
+
Runner2.run({})
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'subscribes to wday 2' do
|
103
|
+
expect(dispatch.subscriptions.all.first.matcher.filters)
|
104
|
+
.to eq('bus_event_type' => 'heartbeat_minutes', 'wday' => '2')
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
93
108
|
context 'when declaring minute intervals' do
|
94
109
|
before do
|
95
110
|
dispatch.on_heartbeat event_name, minute_interval: 5 do |_event|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queue-bus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Leonard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|