localjob 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/localjob/channel.rb +0 -7
- data/lib/localjob/linux_adapter.rb +9 -0
- data/lib/localjob/sysv_adapter.rb +15 -13
- data/lib/localjob/version.rb +1 -1
- data/lib/localjob.rb +7 -2
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1b3b73b7b6d29292e899fbc6e3dd8ec230bfd8c
|
4
|
+
data.tar.gz: 18b94b58722de37178649a63ec0ce04e269295a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fed832f36a4f04b3f4ce3c606090c88868d5c9d3556e5db0276033bc2819be697c947f5454d750c8aab59f91b6c039af809feffb9383c98533a29a3dc6dd91c
|
7
|
+
data.tar.gz: 62861fd26776063bedd58f77593c15ec75ff76ed818f87b703493a8d5dd0c51f3e9991a22c663f609df380e91ced6598a892d780c95c753fce052900f1c35f62
|
data/README.md
CHANGED
data/lib/localjob/channel.rb
CHANGED
@@ -10,13 +10,6 @@ class Localjob
|
|
10
10
|
@queues << queue_from_name(queue)
|
11
11
|
end
|
12
12
|
|
13
|
-
def shift
|
14
|
-
(queue,), = IO.select(@queues)
|
15
|
-
queue.shift
|
16
|
-
rescue POSIX::Mqueue::QueueEmpty
|
17
|
-
retry
|
18
|
-
end
|
19
|
-
|
20
13
|
private
|
21
14
|
def queue_from_name(queue)
|
22
15
|
queue.instance_of?(Localjob) ? queue : Localjob.new(queue)
|
@@ -10,36 +10,38 @@ class Localjob
|
|
10
10
|
|
11
11
|
class SysvAdapter
|
12
12
|
include SysVIPC
|
13
|
-
attr_reader :mqueue
|
14
13
|
|
15
14
|
def initialize(name)
|
16
15
|
@filename = "/tmp/#{name}"
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@mq
|
16
|
+
end
|
17
|
+
|
18
|
+
def mq
|
19
|
+
unless @mq
|
20
|
+
File.open(@filename, "w") { }
|
21
|
+
key = ftok(@filename, 0)
|
22
|
+
|
23
|
+
@mq = MessageQueue.new(key, IPC_CREAT | 0600)
|
24
|
+
end
|
25
|
+
|
26
|
+
@mq
|
21
27
|
end
|
22
28
|
|
23
29
|
def receive
|
24
|
-
|
30
|
+
mq.receive(0, 8024)
|
25
31
|
end
|
26
32
|
|
27
33
|
def send(message)
|
28
|
-
|
34
|
+
mq.send(1, message)
|
29
35
|
end
|
30
36
|
|
31
37
|
def size
|
32
|
-
|
38
|
+
mq.ipc_stat.msg_qnum
|
33
39
|
end
|
34
40
|
|
35
41
|
def destroy
|
36
42
|
File.delete(@filename)
|
37
43
|
@mq.rm
|
38
|
-
|
39
|
-
|
40
|
-
private
|
41
|
-
def fix_queue_name(name)
|
42
|
-
name.start_with?('/') ? name : "/#{name}"
|
44
|
+
@mq = nil
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
data/lib/localjob/version.rb
CHANGED
data/lib/localjob.rb
CHANGED
@@ -6,6 +6,13 @@ require "localjob/version"
|
|
6
6
|
require 'localjob/channel'
|
7
7
|
require 'localjob/worker'
|
8
8
|
|
9
|
+
case RUBY_PLATFORM
|
10
|
+
when /linux/
|
11
|
+
require 'localjob/linux_adapter'
|
12
|
+
else
|
13
|
+
require 'localjob/sysv_adapter'
|
14
|
+
end
|
15
|
+
|
9
16
|
class Localjob
|
10
17
|
extend Forwardable
|
11
18
|
|
@@ -27,10 +34,8 @@ class Localjob
|
|
27
34
|
|
28
35
|
case RUBY_PLATFORM
|
29
36
|
when /linux/
|
30
|
-
require 'localjob/linux_adapter'
|
31
37
|
@queue = LinuxAdapter.new(@name)
|
32
38
|
else
|
33
|
-
require 'localjob/sysv_adapter'
|
34
39
|
@queue = SysvAdapter.new(@name)
|
35
40
|
end
|
36
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localjob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Eskildsen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -142,4 +142,3 @@ test_files:
|
|
142
142
|
- test/mock_adapter.rb
|
143
143
|
- test/test_helper.rb
|
144
144
|
- test/worker_test.rb
|
145
|
-
has_rdoc:
|