async-job 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/async/job/backend/aggregate/server.rb +40 -13
- data/lib/async/job/backend/inline/server.rb +8 -0
- data/lib/async/job/backend/redis/server.rb +24 -4
- data/lib/async/job/buffer.rb +12 -0
- data/lib/async/job/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71fdcce6742cea5cfaeac68e800c56f1dbfa5ea6849503544c35912675874838
|
4
|
+
data.tar.gz: a607a76328c14cee24618479efd1d6924adc5634d7a89d21df0ccccbea78b1d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bc8ac06036c862eb827af97ef43764dd44036dc14cdb5f988a294fc2dbbac5f441b32d71cd6551aa3000c190de82105fcce65771ced7b67d08a8f24e598c872
|
7
|
+
data.tar.gz: 145098c24c1a115d018a4ecc8a1796aa295c4cfb85b8099c30c2e82c9a89fd31780e525015e799a12be807e748c824f299ac88677afdf0764f7b1594094b758e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -28,34 +28,61 @@ module Async
|
|
28
28
|
Console::Event::Failure.for(error).emit(self, "Could not flush #{jobs.size} jobs.")
|
29
29
|
end
|
30
30
|
|
31
|
-
def run
|
31
|
+
def run(task)
|
32
32
|
while true
|
33
33
|
while @pending.empty?
|
34
34
|
@ready.wait
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
task.defer_stop do
|
38
|
+
# Swap the buffers:
|
39
|
+
@pending, @processing = @processing, @pending
|
40
|
+
|
41
|
+
flush(@processing)
|
42
|
+
end
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
# Start the background processing task if it is not already running.
|
47
|
+
#
|
48
|
+
# @return [Boolean] true if the task was started, false if it was already running.
|
49
|
+
protected def start!(parent: Async::Task.current)
|
50
|
+
return false if @task
|
51
|
+
|
52
|
+
# We are creating a task:
|
53
|
+
@task = true
|
54
|
+
|
55
|
+
parent.async(transient: true, annotation: self.class.name) do |task|
|
56
|
+
@task = task
|
57
|
+
|
58
|
+
run(task)
|
47
59
|
ensure
|
48
60
|
# Ensure that all jobs are flushed before we exit:
|
49
|
-
flush(@
|
50
|
-
flush(@
|
61
|
+
flush(@processing) if @processing.any?
|
62
|
+
flush(@pending) if @pending.any?
|
63
|
+
@task = nil
|
51
64
|
end
|
65
|
+
|
66
|
+
return true
|
52
67
|
end
|
53
68
|
|
69
|
+
# Enqueue a job into the pending buffer.
|
70
|
+
#
|
71
|
+
# Start the background processing task if it is not already running.
|
54
72
|
def call(job)
|
55
|
-
start!
|
56
|
-
|
57
73
|
@pending << job
|
58
|
-
|
74
|
+
|
75
|
+
start! or @ready.signal
|
76
|
+
end
|
77
|
+
|
78
|
+
def start
|
79
|
+
@delegate&.start
|
80
|
+
self.start!
|
81
|
+
end
|
82
|
+
|
83
|
+
def stop
|
84
|
+
@task&.stop
|
85
|
+
@delegate&.stop
|
59
86
|
end
|
60
87
|
end
|
61
88
|
end
|
@@ -36,17 +36,37 @@ module Async
|
|
36
36
|
@parent = parent || Async::Idler.new
|
37
37
|
end
|
38
38
|
|
39
|
+
def start!
|
40
|
+
return false if @task
|
41
|
+
|
42
|
+
@task = true
|
43
|
+
|
44
|
+
@parent.async(transient: true, annotation: self.class.name) do |task|
|
45
|
+
@task = task
|
46
|
+
|
47
|
+
while true
|
48
|
+
self.dequeue(task)
|
49
|
+
end
|
50
|
+
ensure
|
51
|
+
@task = nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
39
55
|
def start
|
40
|
-
|
56
|
+
@delegate&.start
|
57
|
+
|
41
58
|
# Start the delayed queue, which will move jobs to the ready queue when they are ready:
|
42
59
|
@delayed_queue.start(@ready_queue, resolution: @resolution)
|
43
60
|
|
44
61
|
# Start the processing queue, which will move jobs to the ready queue when they are abandoned:
|
45
62
|
@processing_queue.start
|
46
63
|
|
47
|
-
|
48
|
-
|
49
|
-
|
64
|
+
self.start!
|
65
|
+
end
|
66
|
+
|
67
|
+
def stop
|
68
|
+
@task&.stop
|
69
|
+
@delegate&.stop
|
50
70
|
end
|
51
71
|
|
52
72
|
def call(job)
|
data/lib/async/job/buffer.rb
CHANGED
@@ -13,6 +13,10 @@ module Async
|
|
13
13
|
@delegate = delegate
|
14
14
|
end
|
15
15
|
|
16
|
+
def empty?
|
17
|
+
@jobs.empty?
|
18
|
+
end
|
19
|
+
|
16
20
|
attr :jobs
|
17
21
|
|
18
22
|
def call(job)
|
@@ -23,6 +27,14 @@ module Async
|
|
23
27
|
def pop
|
24
28
|
@jobs.dequeue
|
25
29
|
end
|
30
|
+
|
31
|
+
def start
|
32
|
+
@delegate&.start
|
33
|
+
end
|
34
|
+
|
35
|
+
def stop
|
36
|
+
@delegate&.stop
|
37
|
+
end
|
26
38
|
end
|
27
39
|
end
|
28
40
|
end
|
data/lib/async/job/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -38,7 +38,7 @@ cert_chain:
|
|
38
38
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
39
39
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
40
40
|
-----END CERTIFICATE-----
|
41
|
-
date: 2024-08-
|
41
|
+
date: 2024-08-08 00:00:00.000000000 Z
|
42
42
|
dependencies:
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: async
|
metadata.gz.sig
CHANGED
Binary file
|