ruote-beanstalk 2.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +140 -0
- data/Rakefile +90 -0
- data/TODO.txt +20 -0
- data/doc/storages.graffle/QuickLook/Preview.pdf +0 -0
- data/doc/storages.graffle/QuickLook/Thumbnail.tiff +0 -0
- data/doc/storages.graffle/data.plist +809 -0
- data/doc/storages.graffle/image1.png +0 -0
- data/doc/storages.graffle/image2.png +0 -0
- data/doc/storages.png +0 -0
- data/lib/ruote-beanstalk.rb +3 -0
- data/lib/ruote/beanstalk.rb +8 -0
- data/lib/ruote/beanstalk/fork.rb +56 -0
- data/lib/ruote/beanstalk/participant.rb +147 -0
- data/lib/ruote/beanstalk/receiver.rb +149 -0
- data/lib/ruote/beanstalk/storage.rb +308 -0
- data/lib/ruote/beanstalk/version.rb +7 -0
- data/ruote-beanstalk.gemspec +85 -0
- data/serve.rb +11 -0
- data/test/functional/base.rb +17 -0
- data/test/functional/ft_0_participant.rb +102 -0
- data/test/functional/ft_1_receiver.rb +112 -0
- data/test/functional/test.rb +9 -0
- data/test/functional_connection.rb +19 -0
- data/test/test.rb +9 -0
- metadata +165 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{ruote-beanstalk}
|
8
|
+
s.version = "2.1.10"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["John Mettraux"]
|
12
|
+
s.date = %q{2010-06-15}
|
13
|
+
s.description = %q{Beanstalk participant/receiver/storage for ruote (a Ruby workflow engine)}
|
14
|
+
s.email = %q{jmettraux@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"CHANGELOG.txt",
|
21
|
+
"LICENSE.txt",
|
22
|
+
"README.md",
|
23
|
+
"Rakefile",
|
24
|
+
"TODO.txt",
|
25
|
+
"doc/storages.graffle/QuickLook/Preview.pdf",
|
26
|
+
"doc/storages.graffle/QuickLook/Thumbnail.tiff",
|
27
|
+
"doc/storages.graffle/data.plist",
|
28
|
+
"doc/storages.graffle/image1.png",
|
29
|
+
"doc/storages.graffle/image2.png",
|
30
|
+
"doc/storages.png",
|
31
|
+
"lib/ruote-beanstalk.rb",
|
32
|
+
"lib/ruote/beanstalk.rb",
|
33
|
+
"lib/ruote/beanstalk/fork.rb",
|
34
|
+
"lib/ruote/beanstalk/participant.rb",
|
35
|
+
"lib/ruote/beanstalk/receiver.rb",
|
36
|
+
"lib/ruote/beanstalk/storage.rb",
|
37
|
+
"lib/ruote/beanstalk/version.rb",
|
38
|
+
"ruote-beanstalk.gemspec",
|
39
|
+
"serve.rb",
|
40
|
+
"test/functional/base.rb",
|
41
|
+
"test/functional/ft_0_participant.rb",
|
42
|
+
"test/functional/ft_1_receiver.rb",
|
43
|
+
"test/functional/test.rb",
|
44
|
+
"test/functional_connection.rb",
|
45
|
+
"test/test.rb"
|
46
|
+
]
|
47
|
+
s.homepage = %q{http://github.com/jmettraux/ruote-beanstalk}
|
48
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
49
|
+
s.require_paths = ["lib"]
|
50
|
+
s.rubyforge_project = %q{ruote}
|
51
|
+
s.rubygems_version = %q{1.3.6}
|
52
|
+
s.summary = %q{Beanstalk participant/receiver/storage for ruote (a Ruby workflow engine)}
|
53
|
+
s.test_files = [
|
54
|
+
"test/test.rb"
|
55
|
+
]
|
56
|
+
|
57
|
+
if s.respond_to? :specification_version then
|
58
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
59
|
+
s.specification_version = 3
|
60
|
+
|
61
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
62
|
+
s.add_runtime_dependency(%q<ruote>, [">= 2.1.10"])
|
63
|
+
s.add_runtime_dependency(%q<rufus-cloche>, [">= 0.1.17"])
|
64
|
+
s.add_runtime_dependency(%q<beanstalk-client>, [">= 1.0.2"])
|
65
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
66
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
67
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
68
|
+
else
|
69
|
+
s.add_dependency(%q<ruote>, [">= 2.1.10"])
|
70
|
+
s.add_dependency(%q<rufus-cloche>, [">= 0.1.17"])
|
71
|
+
s.add_dependency(%q<beanstalk-client>, [">= 1.0.2"])
|
72
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
73
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
74
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
75
|
+
end
|
76
|
+
else
|
77
|
+
s.add_dependency(%q<ruote>, [">= 2.1.10"])
|
78
|
+
s.add_dependency(%q<rufus-cloche>, [">= 0.1.17"])
|
79
|
+
s.add_dependency(%q<beanstalk-client>, [">= 1.0.2"])
|
80
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
81
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
82
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
data/serve.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
ruote_lib = File.expand_path(
|
3
|
+
File.join(File.dirname(__FILE__), %w[ .. .. .. ruote lib ]))
|
4
|
+
ruote_beanstalk_lib = File.expand_path(
|
5
|
+
File.join(File.dirname(__FILE__), %w[ .. .. lib ]))
|
6
|
+
|
7
|
+
$:.unshift(ruote_lib)
|
8
|
+
$:.unshift(ruote_beanstalk_lib)
|
9
|
+
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
require 'rubygems'
|
13
|
+
require 'yajl'
|
14
|
+
|
15
|
+
require 'ruote'
|
16
|
+
require 'ruote/beanstalk'
|
17
|
+
|
@@ -0,0 +1,102 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote-beanstalk
|
4
|
+
#
|
5
|
+
# Mon Jun 14 16:11:02 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), 'base')
|
9
|
+
|
10
|
+
|
11
|
+
class FtParticipantTest < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def setup
|
14
|
+
|
15
|
+
@bs_pid = Ruote::Beanstalk.fork(
|
16
|
+
:address => '127.0.0.1',
|
17
|
+
:port => 11300,
|
18
|
+
:no_kill_at_exit => true,
|
19
|
+
:quiet => true)
|
20
|
+
|
21
|
+
sleep 0.100
|
22
|
+
|
23
|
+
@engine = Ruote::Engine.new(Ruote::Worker.new(Ruote::HashStorage.new()))
|
24
|
+
end
|
25
|
+
|
26
|
+
def teardown
|
27
|
+
|
28
|
+
Process.kill(9, @bs_pid) if @bs_pid
|
29
|
+
end
|
30
|
+
|
31
|
+
class Watcher
|
32
|
+
|
33
|
+
attr_reader :jobs
|
34
|
+
|
35
|
+
def initialize (port, tube=nil)
|
36
|
+
|
37
|
+
@connection = ::Beanstalk::Connection.new("127.0.0.1:#{port}", tube)
|
38
|
+
|
39
|
+
@jobs = []
|
40
|
+
|
41
|
+
@thread = Thread.new do
|
42
|
+
begin
|
43
|
+
loop do
|
44
|
+
job = @connection.reserve
|
45
|
+
job.delete
|
46
|
+
@jobs << Rufus::Json.decode(job.body)
|
47
|
+
end
|
48
|
+
rescue Exception => e
|
49
|
+
#p e
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_participant
|
56
|
+
|
57
|
+
@engine.register_participant(
|
58
|
+
:alpha,
|
59
|
+
Ruote::Beanstalk::BsParticipant,
|
60
|
+
'beanstalk' => '127.0.0.1:11300')
|
61
|
+
|
62
|
+
watcher = Watcher.new(11300)
|
63
|
+
|
64
|
+
#@engine.context.logger.noisy = true
|
65
|
+
|
66
|
+
wfid = @engine.launch(Ruote.define do
|
67
|
+
alpha
|
68
|
+
end)
|
69
|
+
|
70
|
+
@engine.wait_for(:alpha)
|
71
|
+
sleep 0.100
|
72
|
+
|
73
|
+
assert_equal 1, watcher.jobs.size
|
74
|
+
assert_equal 'workitem', watcher.jobs.first.first
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_participant_tube
|
78
|
+
|
79
|
+
@engine.register_participant(
|
80
|
+
:alpha,
|
81
|
+
Ruote::Beanstalk::BsParticipant,
|
82
|
+
'beanstalk' => '127.0.0.1:11300',
|
83
|
+
'tube' => 'underground')
|
84
|
+
|
85
|
+
watcher0 = Watcher.new(11300)
|
86
|
+
watcher1 = Watcher.new(11300, 'underground')
|
87
|
+
|
88
|
+
#@engine.context.logger.noisy = true
|
89
|
+
|
90
|
+
wfid = @engine.launch(Ruote.define do
|
91
|
+
alpha
|
92
|
+
end)
|
93
|
+
|
94
|
+
@engine.wait_for(:alpha)
|
95
|
+
sleep 0.100
|
96
|
+
|
97
|
+
assert_equal 0, watcher0.jobs.size
|
98
|
+
assert_equal 1, watcher1.jobs.size
|
99
|
+
assert_equal 'workitem', watcher1.jobs.first.first
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
#
|
4
|
+
# testing ruote-beanstalk
|
5
|
+
#
|
6
|
+
# Mon Jun 14 19:43:57 JST 2010
|
7
|
+
#
|
8
|
+
|
9
|
+
require File.join(File.dirname(__FILE__), 'base')
|
10
|
+
|
11
|
+
|
12
|
+
class FtParticipantTest < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup
|
15
|
+
|
16
|
+
@bs_pid = Ruote::Beanstalk.fork(
|
17
|
+
:address => '127.0.0.1',
|
18
|
+
:port => 11300,
|
19
|
+
:no_kill_at_exit => true,
|
20
|
+
:quiet => true)
|
21
|
+
|
22
|
+
sleep 0.100
|
23
|
+
|
24
|
+
@engine = Ruote::Engine.new(Ruote::Worker.new(Ruote::HashStorage.new()))
|
25
|
+
end
|
26
|
+
|
27
|
+
def teardown
|
28
|
+
|
29
|
+
Process.kill(9, @bs_pid) if @bs_pid
|
30
|
+
end
|
31
|
+
|
32
|
+
class HelloServer
|
33
|
+
|
34
|
+
def initialize (port, tube_in, tube_out)
|
35
|
+
|
36
|
+
@connection = ::Beanstalk::Connection.new("127.0.0.1:#{port}", tube_in)
|
37
|
+
|
38
|
+
@thread = Thread.new do
|
39
|
+
begin
|
40
|
+
loop do
|
41
|
+
|
42
|
+
job = @connection.reserve
|
43
|
+
job.delete
|
44
|
+
|
45
|
+
payload = Rufus::Json.decode(job.body)
|
46
|
+
payload.last['fields']['hello'] = 'world'
|
47
|
+
|
48
|
+
@connection.use(tube_out)
|
49
|
+
@connection.put(Rufus::Json.encode(payload))
|
50
|
+
end
|
51
|
+
rescue Exception => e
|
52
|
+
#p e
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_participant_and_receiver
|
59
|
+
|
60
|
+
@engine.register_participant(
|
61
|
+
:alpha,
|
62
|
+
Ruote::Beanstalk::BsParticipant,
|
63
|
+
'beanstalk' => '127.0.0.1:11300',
|
64
|
+
'tube' => 'in')
|
65
|
+
|
66
|
+
Ruote::Beanstalk::BsReceiver.new(
|
67
|
+
@engine, '127.0.0.1:11300', :tube => 'out')
|
68
|
+
|
69
|
+
echo = HelloServer.new(11300, 'in', 'out')
|
70
|
+
|
71
|
+
#@engine.context.logger.noisy = true
|
72
|
+
|
73
|
+
wfid = @engine.launch(Ruote.define do
|
74
|
+
alpha
|
75
|
+
end)
|
76
|
+
|
77
|
+
r = @engine.wait_for(wfid)
|
78
|
+
|
79
|
+
assert_equal 'world', r['workitem']['fields']['hello']
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_launchitem
|
83
|
+
|
84
|
+
sp = @engine.register_participant '.+', Ruote::StorageParticipant
|
85
|
+
|
86
|
+
Ruote::Beanstalk::BsReceiver.new(
|
87
|
+
@engine, '127.0.0.1:11300', :tube => 'launch')
|
88
|
+
|
89
|
+
#@engine.context.logger.noisy = true
|
90
|
+
|
91
|
+
pdef = Ruote.process_definition do
|
92
|
+
alpha
|
93
|
+
end
|
94
|
+
|
95
|
+
#fields = { 'hello' => '上海' }
|
96
|
+
fields = { 'hello' => 'shangai' }
|
97
|
+
|
98
|
+
launchitem = [ 'launchitem', [ pdef, fields, {} ] ]
|
99
|
+
|
100
|
+
con = ::Beanstalk::Connection.new('127.0.0.1:11300')
|
101
|
+
con.use('launch')
|
102
|
+
con.put(Rufus::Json.encode(launchitem))
|
103
|
+
|
104
|
+
sleep 1
|
105
|
+
|
106
|
+
assert_equal 1, sp.size
|
107
|
+
assert_equal 'alpha', sp.first.participant_name
|
108
|
+
#assert_equal '上海', sp.first.fields['hello']
|
109
|
+
assert_equal 'shangai', sp.first.fields['hello']
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
#
|
3
|
+
# testing ruote-beanstalk
|
4
|
+
#
|
5
|
+
# Mon May 3 19:00:00 JST 2010
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'yajl' rescue require 'json'
|
9
|
+
require 'rufus-json'
|
10
|
+
Rufus::Json.detect_backend
|
11
|
+
|
12
|
+
require 'ruote/beanstalk'
|
13
|
+
|
14
|
+
|
15
|
+
def new_storage (opts)
|
16
|
+
|
17
|
+
Ruote::Beanstalk::BsStorage.new('127.0.0.1:11300', opts)
|
18
|
+
end
|
19
|
+
|
data/test/test.rb
ADDED
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruote-beanstalk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 2
|
7
|
+
- 1
|
8
|
+
- 10
|
9
|
+
version: 2.1.10
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- John Mettraux
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-06-15 00:00:00 +09:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: ruote
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 1
|
30
|
+
- 10
|
31
|
+
version: 2.1.10
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rufus-cloche
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 1
|
44
|
+
- 17
|
45
|
+
version: 0.1.17
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: beanstalk-client
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 1
|
57
|
+
- 0
|
58
|
+
- 2
|
59
|
+
version: 1.0.2
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: yard
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
72
|
+
type: :development
|
73
|
+
version_requirements: *id004
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: rake
|
76
|
+
prerelease: false
|
77
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
version: "0"
|
84
|
+
type: :development
|
85
|
+
version_requirements: *id005
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: jeweler
|
88
|
+
prerelease: false
|
89
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
type: :development
|
97
|
+
version_requirements: *id006
|
98
|
+
description: Beanstalk participant/receiver/storage for ruote (a Ruby workflow engine)
|
99
|
+
email: jmettraux@gmail.com
|
100
|
+
executables: []
|
101
|
+
|
102
|
+
extensions: []
|
103
|
+
|
104
|
+
extra_rdoc_files:
|
105
|
+
- LICENSE.txt
|
106
|
+
- README.md
|
107
|
+
files:
|
108
|
+
- CHANGELOG.txt
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- TODO.txt
|
113
|
+
- doc/storages.graffle/QuickLook/Preview.pdf
|
114
|
+
- doc/storages.graffle/QuickLook/Thumbnail.tiff
|
115
|
+
- doc/storages.graffle/data.plist
|
116
|
+
- doc/storages.graffle/image1.png
|
117
|
+
- doc/storages.graffle/image2.png
|
118
|
+
- doc/storages.png
|
119
|
+
- lib/ruote-beanstalk.rb
|
120
|
+
- lib/ruote/beanstalk.rb
|
121
|
+
- lib/ruote/beanstalk/fork.rb
|
122
|
+
- lib/ruote/beanstalk/participant.rb
|
123
|
+
- lib/ruote/beanstalk/receiver.rb
|
124
|
+
- lib/ruote/beanstalk/storage.rb
|
125
|
+
- lib/ruote/beanstalk/version.rb
|
126
|
+
- ruote-beanstalk.gemspec
|
127
|
+
- serve.rb
|
128
|
+
- test/functional/base.rb
|
129
|
+
- test/functional/ft_0_participant.rb
|
130
|
+
- test/functional/ft_1_receiver.rb
|
131
|
+
- test/functional/test.rb
|
132
|
+
- test/functional_connection.rb
|
133
|
+
- test/test.rb
|
134
|
+
has_rdoc: true
|
135
|
+
homepage: http://github.com/jmettraux/ruote-beanstalk
|
136
|
+
licenses: []
|
137
|
+
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options:
|
140
|
+
- --charset=UTF-8
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
segments:
|
148
|
+
- 0
|
149
|
+
version: "0"
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
version: "0"
|
157
|
+
requirements: []
|
158
|
+
|
159
|
+
rubyforge_project: ruote
|
160
|
+
rubygems_version: 1.3.6
|
161
|
+
signing_key:
|
162
|
+
specification_version: 3
|
163
|
+
summary: Beanstalk participant/receiver/storage for ruote (a Ruby workflow engine)
|
164
|
+
test_files:
|
165
|
+
- test/test.rb
|