perfectqueue 0.8.46 → 0.8.47
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/.travis.yml +4 -0
- data/ChangeLog +5 -0
- data/lib/perfectqueue.rb +31 -37
- data/lib/perfectqueue/backend.rb +2 -12
- data/lib/perfectqueue/backend/rdb_compat.rb +1 -6
- data/lib/perfectqueue/blocking_flag.rb +0 -1
- data/lib/perfectqueue/daemons_logger.rb +0 -2
- data/lib/perfectqueue/multiprocess/fork_processor.rb +0 -1
- data/lib/perfectqueue/signal_thread.rb +0 -2
- data/lib/perfectqueue/version.rb +1 -1
- metadata +3 -4
- data/lib/perfectqueue/multiprocess.rb +0 -31
- data/lib/perfectqueue/signal_queue.rb +0 -122
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68a42f45b43150785b9c0a0ad1e6757da6b8104f
|
4
|
+
data.tar.gz: 64b1df2f881992eaf48f1811b323966c35cdfccd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa3effbb36e362da777ef15ab8aba0feb76471d150e7ae887cf299d90cf48d785f90b3f976907ad0e0fe6256ea7dd4bfa5198676e931a581778aae5c3dcfb677
|
7
|
+
data.tar.gz: 4235badb3ba5fdc97d570e14fed8c3d405c7b9d5fe98ee7962b7df3bc2bfef730a275aef241418d61fdc1d9a02e0b8401a8e5979a53af21c59428bd2be5ab5d3
|
data/.travis.yml
CHANGED
data/ChangeLog
CHANGED
data/lib/perfectqueue.rb
CHANGED
@@ -16,45 +16,39 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
require 'json'
|
20
|
+
require 'thread' # Mutex, CoditionVariable
|
21
|
+
require 'zlib'
|
22
|
+
require 'stringio'
|
23
|
+
require 'sequel'
|
24
|
+
require 'logger'
|
25
|
+
require 'fcntl'
|
22
26
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
:SignalThread => 'perfectqueue/signal_thread',
|
47
|
-
:VERSION => 'perfectqueue/version',
|
48
|
-
}.each_pair {|k,v|
|
49
|
-
autoload k, File.expand_path(v, File.dirname(__FILE__))
|
50
|
-
}
|
51
|
-
[
|
52
|
-
'perfectqueue/multiprocess',
|
53
|
-
'perfectqueue/error',
|
54
|
-
].each {|v|
|
55
|
-
require File.expand_path(v, File.dirname(__FILE__))
|
56
|
-
}
|
27
|
+
require_relative 'perfectqueue/application'
|
28
|
+
require_relative 'perfectqueue/backend'
|
29
|
+
require_relative 'perfectqueue/backend/rdb_compat'
|
30
|
+
require_relative 'perfectqueue/blocking_flag'
|
31
|
+
require_relative 'perfectqueue/client'
|
32
|
+
require_relative 'perfectqueue/daemons_logger'
|
33
|
+
require_relative 'perfectqueue/engine'
|
34
|
+
require_relative 'perfectqueue/model'
|
35
|
+
require_relative 'perfectqueue/queue'
|
36
|
+
require_relative 'perfectqueue/runner'
|
37
|
+
require_relative 'perfectqueue/task_monitor'
|
38
|
+
require_relative 'perfectqueue/task_metadata'
|
39
|
+
require_relative 'perfectqueue/task_status'
|
40
|
+
require_relative 'perfectqueue/task'
|
41
|
+
require_relative 'perfectqueue/worker'
|
42
|
+
require_relative 'perfectqueue/supervisor'
|
43
|
+
require_relative 'perfectqueue/signal_thread'
|
44
|
+
require_relative 'perfectqueue/version'
|
45
|
+
require_relative 'perfectqueue/multiprocess/thread_processor'
|
46
|
+
require_relative 'perfectqueue/multiprocess/child_process'
|
47
|
+
require_relative 'perfectqueue/multiprocess/child_process_monitor'
|
48
|
+
require_relative 'perfectqueue/multiprocess/fork_processor'
|
49
|
+
require_relative 'perfectqueue/error'
|
57
50
|
|
51
|
+
module PerfectQueue
|
58
52
|
def self.open(config, &block)
|
59
53
|
c = Client.new(config)
|
60
54
|
begin
|
data/lib/perfectqueue/backend.rb
CHANGED
@@ -19,17 +19,8 @@
|
|
19
19
|
module PerfectQueue
|
20
20
|
module Backend
|
21
21
|
def self.new_backend(client, config)
|
22
|
-
|
23
|
-
|
24
|
-
raise ConfigError, "'type' option is not set"
|
25
|
-
when 'rdb_compat'
|
26
|
-
require_backend('rdb_compat')
|
27
|
-
RDBCompatBackend.new(client, config)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.require_backend(fname)
|
32
|
-
require File.expand_path("backend/#{fname}", File.dirname(__FILE__))
|
22
|
+
raise ConfigError, "'type' must be 'rdb_compat'" if config[:type] != 'rdb_compat'
|
23
|
+
RDBCompatBackend.new(client, config)
|
33
24
|
end
|
34
25
|
end
|
35
26
|
|
@@ -46,4 +37,3 @@ module PerfectQueue
|
|
46
37
|
end
|
47
38
|
end
|
48
39
|
end
|
49
|
-
|
@@ -39,7 +39,6 @@ module PerfectQueue
|
|
39
39
|
def initialize(client, config)
|
40
40
|
super
|
41
41
|
|
42
|
-
require 'sequel'
|
43
42
|
url = config[:url]
|
44
43
|
@table = config[:table]
|
45
44
|
unless @table
|
@@ -170,8 +169,6 @@ SQL
|
|
170
169
|
|
171
170
|
def compress_data(data, compression)
|
172
171
|
if compression == 'gzip'
|
173
|
-
require 'zlib'
|
174
|
-
require 'stringio'
|
175
172
|
io = StringIO.new
|
176
173
|
io.set_encoding(Encoding::ASCII_8BIT)
|
177
174
|
gz = Zlib::GzipWriter.new(io)
|
@@ -243,7 +240,7 @@ SQL
|
|
243
240
|
return nil
|
244
241
|
end
|
245
242
|
|
246
|
-
sql = "UPDATE `#{@table}` SET timeout=? WHERE timeout <= ? AND id IN ("
|
243
|
+
sql = "UPDATE `#{@table}` FORCE INDEX (PRIMARY) SET timeout=? WHERE timeout <= ? AND id IN ("
|
247
244
|
params = [sql, next_timeout, now]
|
248
245
|
tasks.each {|t| params << t.key }
|
249
246
|
sql << (1..tasks.size).map { '?' }.join(',')
|
@@ -410,8 +407,6 @@ SQL
|
|
410
407
|
# automatic gzip decompression
|
411
408
|
d.force_encoding('ASCII-8BIT') if d.respond_to?(:force_encoding)
|
412
409
|
if d[0, 2] == GZIP_MAGIC_BYTES
|
413
|
-
require 'zlib'
|
414
|
-
require 'stringio'
|
415
410
|
compression = 'gzip'
|
416
411
|
gz = Zlib::GzipReader.new(StringIO.new(d))
|
417
412
|
begin
|
data/lib/perfectqueue/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: perfectqueue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.47
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -112,14 +112,12 @@ files:
|
|
112
112
|
- lib/perfectqueue/engine.rb
|
113
113
|
- lib/perfectqueue/error.rb
|
114
114
|
- lib/perfectqueue/model.rb
|
115
|
-
- lib/perfectqueue/multiprocess.rb
|
116
115
|
- lib/perfectqueue/multiprocess/child_process.rb
|
117
116
|
- lib/perfectqueue/multiprocess/child_process_monitor.rb
|
118
117
|
- lib/perfectqueue/multiprocess/fork_processor.rb
|
119
118
|
- lib/perfectqueue/multiprocess/thread_processor.rb
|
120
119
|
- lib/perfectqueue/queue.rb
|
121
120
|
- lib/perfectqueue/runner.rb
|
122
|
-
- lib/perfectqueue/signal_queue.rb
|
123
121
|
- lib/perfectqueue/signal_thread.rb
|
124
122
|
- lib/perfectqueue/supervisor.rb
|
125
123
|
- lib/perfectqueue/task.rb
|
@@ -202,3 +200,4 @@ test_files:
|
|
202
200
|
- spec/task_metadata_spec.rb
|
203
201
|
- spec/task_monitor_spec.rb
|
204
202
|
- spec/task_spec.rb
|
203
|
+
has_rdoc: false
|
@@ -1,31 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# PerfectQueue
|
3
|
-
#
|
4
|
-
# Copyright (C) 2012-2013 Sadayuki Furuhashi
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
module PerfectQueue
|
20
|
-
module Multiprocess
|
21
|
-
{
|
22
|
-
:ChildProcess => 'multiprocess/child_process',
|
23
|
-
:ChildProcessMonitor => 'multiprocess/child_process_monitor',
|
24
|
-
:ForkProcessor => 'multiprocess/fork_processor',
|
25
|
-
:ThreadProcessor => 'multiprocess/thread_processor',
|
26
|
-
}.each_pair {|k,v|
|
27
|
-
autoload k, File.expand_path(v, File.dirname(__FILE__))
|
28
|
-
}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
@@ -1,122 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# PerfectQueue
|
3
|
-
#
|
4
|
-
# Copyright (C) 2012-2013 Sadayuki Furuhashi
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
module PerfectQueue
|
20
|
-
|
21
|
-
# SignalQueue is obsolete because it does not run with ruby >= 2.0.0.
|
22
|
-
# See ddbf04c9 and use SignalThread instead.
|
23
|
-
class SignalQueue
|
24
|
-
def self.start(&block)
|
25
|
-
st = new(&block)
|
26
|
-
st.start
|
27
|
-
return st
|
28
|
-
end
|
29
|
-
|
30
|
-
def initialize(&block)
|
31
|
-
require 'thread'
|
32
|
-
|
33
|
-
@handlers = {}
|
34
|
-
@queue = []
|
35
|
-
@mutex = Mutex.new
|
36
|
-
@cond = ConditionVariable.new
|
37
|
-
@finished = false
|
38
|
-
|
39
|
-
block.call(self) if block
|
40
|
-
end
|
41
|
-
|
42
|
-
def trap(sig, command=nil, &block)
|
43
|
-
sig = sig.to_sym
|
44
|
-
old = @handlers[sig]
|
45
|
-
|
46
|
-
if block
|
47
|
-
Kernel.trap(sig) do
|
48
|
-
enqueue(sig)
|
49
|
-
end
|
50
|
-
@handlers[sig] = block
|
51
|
-
|
52
|
-
else
|
53
|
-
Kernel.trap(sig, command)
|
54
|
-
@handlers.delete(sig)
|
55
|
-
end
|
56
|
-
|
57
|
-
old
|
58
|
-
end
|
59
|
-
|
60
|
-
def start
|
61
|
-
@thread = Thread.new(&method(:run))
|
62
|
-
end
|
63
|
-
|
64
|
-
def join
|
65
|
-
@thread.join
|
66
|
-
end
|
67
|
-
|
68
|
-
def stop
|
69
|
-
@finished = true
|
70
|
-
enqueue(nil) # TODO causes recursive lock?
|
71
|
-
end
|
72
|
-
|
73
|
-
def shutdown
|
74
|
-
stop
|
75
|
-
join
|
76
|
-
end
|
77
|
-
|
78
|
-
def run
|
79
|
-
@owner_thread = Thread.current
|
80
|
-
until @finished
|
81
|
-
h = nil
|
82
|
-
@mutex.synchronize do
|
83
|
-
while @queue.empty?
|
84
|
-
@cond.wait(@mutex, 0.5)
|
85
|
-
end
|
86
|
-
sig = @queue.shift
|
87
|
-
if sig == nil
|
88
|
-
@finished = true
|
89
|
-
else
|
90
|
-
h = @handlers[sig]
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
begin
|
95
|
-
h.call if h
|
96
|
-
rescue
|
97
|
-
STDERR.print "#{$!}\n"
|
98
|
-
$!.backtrace.each {|bt|
|
99
|
-
STDERR.print "\t#{bt}\n"
|
100
|
-
STDERR.flush
|
101
|
-
}
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
private
|
107
|
-
def enqueue(sig)
|
108
|
-
if Thread.current == @owner_thread
|
109
|
-
@queue << sig
|
110
|
-
if @mutex.locked?
|
111
|
-
@cond.signal
|
112
|
-
end
|
113
|
-
else
|
114
|
-
@mutex.synchronize do
|
115
|
-
@queue << sig
|
116
|
-
@cond.signal
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
end
|