async-job 0.7.0 → 0.7.1
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 +34 -13
- data/lib/async/job/buffer.rb +4 -0
- data/lib/async/job/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- 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: 5168ca3167c401c68ffca433ef65962420641cd4826e1d1fb9e4700bf5c9a5c8
|
4
|
+
data.tar.gz: da6da3de6436cc9c1ade6523610033c683bafff75aa84640b12826b7d95cacfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fb44c033b61704b4b5cb2d0b6ad2351d71c35d2f63c96efca439478c75e404e80e31caa91fe291d07e537bb3bd47d1114153071d49f78c7a33fc14e6ab6cab2
|
7
|
+
data.tar.gz: 8371e91c27a9701cf34dacf575596c9af03dbbaa188837df5a6e90d9110f80d54056cd757b399a0e715f2a6268e128c7ee346dd2634fae40bd83f031f3bf7ad5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -28,34 +28,55 @@ 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 stop
|
79
|
+
@task&.stop
|
59
80
|
end
|
60
81
|
end
|
61
82
|
end
|
data/lib/async/job/buffer.rb
CHANGED
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.7.
|
4
|
+
version: 0.7.1
|
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
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
rubygems_version: 3.5.
|
119
|
+
rubygems_version: 3.5.13
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: A asynchronous job queue for Ruby.
|
metadata.gz.sig
CHANGED
Binary file
|