em-synchrony 0.2.0 → 0.3.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +2 -2
- data/em-synchrony.gemspec +2 -3
- data/lib/em-synchrony.rb +1 -1
- data/lib/em-synchrony/em-http.rb +1 -1
- data/lib/em-synchrony/em-redis.rb +5 -3
- data/spec/http_spec.rb +12 -0
- metadata +20 -13
data/.gitignore
ADDED
data/Gemfile
CHANGED
@@ -4,12 +4,12 @@ gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git'
|
|
4
4
|
|
5
5
|
group :development do
|
6
6
|
gem 'rspec', '~> 2.0.0'
|
7
|
-
gem 'em-http-request'
|
7
|
+
gem 'em-http-request', :git => 'git://github.com/igrigorik/em-http-request'
|
8
8
|
gem 'remcached'
|
9
9
|
gem 'em-mongo'
|
10
10
|
gem 'bson_ext'
|
11
11
|
gem 'mysqlplus'
|
12
12
|
gem 'em-mysqlplus'
|
13
|
-
gem 'em-redis'
|
13
|
+
gem 'em-redis', '~> 0.3.0'
|
14
14
|
gem 'mongo'
|
15
15
|
end
|
data/em-synchrony.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "em-synchrony"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.3.0.beta.1"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Ilya Grigorik"]
|
9
9
|
s.email = ["ilya@igvita.com"]
|
@@ -13,8 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.rubyforge_project = "em-synchrony"
|
15
15
|
|
16
|
-
s.
|
17
|
-
s.add_runtime_dependency("eventmachine", [">= 0.12.9"])
|
16
|
+
s.add_runtime_dependency("eventmachine", ">= 1.0.0.beta.1")
|
18
17
|
|
19
18
|
s.files = `git ls-files`.split("\n")
|
20
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/em-synchrony.rb
CHANGED
@@ -12,7 +12,7 @@ require "em-synchrony/thread"
|
|
12
12
|
require "em-synchrony/em-multi"
|
13
13
|
require "em-synchrony/tcpsocket"
|
14
14
|
require "em-synchrony/connection_pool"
|
15
|
-
require "em-synchrony/iterator"
|
15
|
+
require "em-synchrony/iterator" if EventMachine::VERSION > '0.12.10'
|
16
16
|
|
17
17
|
module EventMachine
|
18
18
|
|
data/lib/em-synchrony/em-http.rb
CHANGED
@@ -21,13 +21,15 @@ module EventMachine
|
|
21
21
|
|
22
22
|
Fiber.yield
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
|
+
alias :old_call_command :call_command
|
26
|
+
|
25
27
|
def call_command(argv, &blk)
|
26
28
|
# async commands are 'a' prefixed, but do check
|
27
29
|
# for the 'add' command corner case (ugh)
|
28
30
|
if argv.first.size > 3 && argv.first[0] == 'a'
|
29
31
|
argv[0] = argv[0].to_s.slice(1,argv[0].size)
|
30
|
-
|
32
|
+
old_call_command(argv, &blk)
|
31
33
|
|
32
34
|
else
|
33
35
|
# wrap response blocks into fiber callbacks
|
@@ -36,7 +38,7 @@ module EventMachine
|
|
36
38
|
blk = proc { |v| v } if !block_given?
|
37
39
|
clb = proc { |v| f.resume(blk.call(v)) }
|
38
40
|
|
39
|
-
|
41
|
+
old_call_command(argv, &clb)
|
40
42
|
Fiber.yield
|
41
43
|
end
|
42
44
|
end
|
data/spec/http_spec.rb
CHANGED
@@ -4,6 +4,18 @@ URL = "http://localhost:8081/"
|
|
4
4
|
DELAY = 0.25
|
5
5
|
|
6
6
|
describe EventMachine::HttpRequest do
|
7
|
+
it "should perform a synchronous fetch" do
|
8
|
+
EM.synchrony do
|
9
|
+
s = StubServer.new("HTTP/1.0 200 OK\r\nConnection: close\r\n\r\nFoo", DELAY)
|
10
|
+
|
11
|
+
r = EventMachine::HttpRequest.new(URL).get
|
12
|
+
r.response.should == 'Foo'
|
13
|
+
|
14
|
+
s.stop
|
15
|
+
EventMachine.stop
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
7
19
|
it "should fire sequential requests" do
|
8
20
|
EventMachine.synchrony do
|
9
21
|
s = StubServer.new("HTTP/1.0 200 OK\r\nConnection: close\r\n\r\nFoo", DELAY)
|
metadata
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-synchrony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: true
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 3
|
8
8
|
- 0
|
9
|
-
|
9
|
+
- beta
|
10
|
+
- 1
|
11
|
+
version: 0.3.0.beta.1
|
10
12
|
platform: ruby
|
11
13
|
authors:
|
12
14
|
- Ilya Grigorik
|
@@ -14,7 +16,7 @@ autorequire:
|
|
14
16
|
bindir: bin
|
15
17
|
cert_chain: []
|
16
18
|
|
17
|
-
date:
|
19
|
+
date: 2011-02-23 00:00:00 -05:00
|
18
20
|
default_executable:
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
@@ -25,10 +27,12 @@ dependencies:
|
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
27
29
|
segments:
|
30
|
+
- 1
|
31
|
+
- 0
|
28
32
|
- 0
|
29
|
-
-
|
30
|
-
-
|
31
|
-
version: 0.
|
33
|
+
- beta
|
34
|
+
- 1
|
35
|
+
version: 1.0.0.beta.1
|
32
36
|
type: :runtime
|
33
37
|
prerelease: false
|
34
38
|
version_requirements: *id001
|
@@ -42,6 +46,7 @@ extensions: []
|
|
42
46
|
extra_rdoc_files: []
|
43
47
|
|
44
48
|
files:
|
49
|
+
- .gitignore
|
45
50
|
- Gemfile
|
46
51
|
- README.md
|
47
52
|
- Rakefile
|
@@ -100,18 +105,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
105
|
requirements:
|
101
106
|
- - ">="
|
102
107
|
- !ruby/object:Gem::Version
|
108
|
+
hash: -1057112667937056146
|
103
109
|
segments:
|
104
|
-
-
|
105
|
-
|
106
|
-
version: "1.9"
|
110
|
+
- 0
|
111
|
+
version: "0"
|
107
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
113
|
none: false
|
109
114
|
requirements:
|
110
|
-
- - "
|
115
|
+
- - ">"
|
111
116
|
- !ruby/object:Gem::Version
|
112
117
|
segments:
|
113
|
-
-
|
114
|
-
|
118
|
+
- 1
|
119
|
+
- 3
|
120
|
+
- 1
|
121
|
+
version: 1.3.1
|
115
122
|
requirements: []
|
116
123
|
|
117
124
|
rubyforge_project: em-synchrony
|