request_queue 0.2.1 → 0.3.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 +4 -4
- data/lib/request_queue.rb +14 -13
- data/lib/request_queue/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb4fadeffad30cc58d4d70f10ab82ba428a0716d
|
4
|
+
data.tar.gz: d3b1f3ca280bad3c268d152a7682289cab0985d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae9b1bf0a3a381c85a134ca470e976dd45d9bb52c1c3cf281de18241b133bf07c505d83fec9eba5bc78d06eccb1f4d434aba16f7417feede8dae59b3a7bc8abc
|
7
|
+
data.tar.gz: 47cde5ad4130e189775c6936e04dc533cb0bc859075b1405fb1cf80e147dc5cbfef61abad3ebf91c7494b1e86734f0227f8290f504cc8381044ca1ca49d81069
|
data/README.md
CHANGED
@@ -90,14 +90,14 @@ When testing, sometimes you want a little more control. As such, `RequestQueue`
|
|
90
90
|
* `:fake` - Never runs jobs, and allows you to inspect the queue with `RequestQueue.queue.queue`.
|
91
91
|
* `:inline` - Runs jobs immediately and never adds them to the queue.
|
92
92
|
|
93
|
-
To change the queueing backend, you can just
|
93
|
+
To change the queueing backend, you can just give the backend name as an argument to process.
|
94
94
|
|
95
95
|
```ruby
|
96
|
-
RequestQueue.
|
96
|
+
RequestQueue.process :inline do
|
97
|
+
# ...
|
98
|
+
end
|
97
99
|
```
|
98
100
|
|
99
|
-
**NOTE:** Only use the `use` method in the testing environment. It is not thread-safe.
|
100
|
-
|
101
101
|
## Development
|
102
102
|
|
103
103
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/request_queue.rb
CHANGED
@@ -17,14 +17,6 @@ module RequestQueue
|
|
17
17
|
end
|
18
18
|
|
19
19
|
class << self
|
20
|
-
def backend
|
21
|
-
@backend || BACKENDS[:default]
|
22
|
-
end
|
23
|
-
|
24
|
-
def use(type)
|
25
|
-
@backend = BACKENDS.fetch(type)
|
26
|
-
end
|
27
|
-
|
28
20
|
def queue=(value)
|
29
21
|
RequestStore.store[:request_queue] = value
|
30
22
|
end
|
@@ -41,12 +33,21 @@ module RequestQueue
|
|
41
33
|
queue << message
|
42
34
|
end
|
43
35
|
|
44
|
-
def process
|
45
|
-
|
46
|
-
|
47
|
-
|
36
|
+
def process(backend = :default)
|
37
|
+
restore do
|
38
|
+
self.queue = BACKENDS.fetch(backend).new
|
39
|
+
yield if block_given?
|
40
|
+
queue.process
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def restore
|
47
|
+
original_queue = self.queue
|
48
|
+
yield
|
48
49
|
ensure
|
49
|
-
self.queue =
|
50
|
+
self.queue = original_queue
|
50
51
|
end
|
51
52
|
end
|
52
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: request_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Zane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: request_store
|