em_aws 0.1.4 → 0.1.5
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.
- data/Gemfile.lock +4 -4
- data/README.md +3 -5
- data/lib/em_aws.rb +2 -19
- data/lib/em_aws/patches.rb +22 -0
- data/lib/em_aws/version.rb +1 -1
- data/spec/em_http_handler_spec.rb +0 -1
- data/spec/patches_spec.rb +48 -0
- data/spec/spec_helper.rb +1 -0
- metadata +15 -15
- data/lib/em_aws/core/session_signer.rb +0 -14
- data/spec/session_signer_spec.rb +0 -17
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
em_aws (0.1.
|
4
|
+
em_aws (0.1.5)
|
5
5
|
aws-sdk
|
6
6
|
em-http-request
|
7
7
|
em-synchrony
|
@@ -10,7 +10,7 @@ GEM
|
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
12
|
addressable (2.2.8)
|
13
|
-
aws-sdk (1.5.
|
13
|
+
aws-sdk (1.5.4)
|
14
14
|
httparty (~> 0.7)
|
15
15
|
json (~> 1.4)
|
16
16
|
nokogiri (>= 1.4.4)
|
@@ -39,8 +39,8 @@ GEM
|
|
39
39
|
json (1.7.3-java)
|
40
40
|
multi_json (1.3.6)
|
41
41
|
multi_xml (0.5.1)
|
42
|
-
nokogiri (1.5.
|
43
|
-
nokogiri (1.5.
|
42
|
+
nokogiri (1.5.4)
|
43
|
+
nokogiri (1.5.4-java)
|
44
44
|
rspec (2.10.0)
|
45
45
|
rspec-core (~> 2.10.0)
|
46
46
|
rspec-expectations (~> 2.10.0)
|
data/README.md
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
#
|
2
|
-
An EM-Synchrony handler for Ruby [AWS-SDK](https://github.com/
|
3
|
-
|
4
|
-
This code has be submitted to AWS-SKD see: [pull request](https://github.com/amazonwebservices/aws-sdk-for-ruby/pull/14).
|
5
|
-
Until approval (or if it is declined) I created this gem.
|
1
|
+
# EmAws
|
2
|
+
An EM-Synchrony handler for Ruby [AWS-SDK](https://github.com/amazonwebservices/aws-sdk-for-ruby/)
|
6
3
|
|
7
4
|
## Installation
|
8
5
|
|
@@ -25,6 +22,7 @@ In your environments files add:
|
|
25
22
|
|
26
23
|
require 'aws-sdk'
|
27
24
|
require 'aws/core/http/em_http_handler'
|
25
|
+
AWS.eager_autoload! # AWS lazyloading is not threadsafe
|
28
26
|
AWS.config(
|
29
27
|
:http_handler => AWS::Http::EMHttpHandler.new(
|
30
28
|
:proxy => {:host => "http://myproxy.com", :port => 80}
|
data/lib/em_aws.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'em_aws/patches'
|
1
2
|
require 'aws-sdk'
|
2
3
|
require 'em_aws/version'
|
3
4
|
require 'em-http'
|
@@ -6,22 +7,4 @@ require 'em-synchrony/em-http'
|
|
6
7
|
require 'aws/core/autoloader'
|
7
8
|
|
8
9
|
AWS.eager_autoload! # lazy load isn't thread safe
|
9
|
-
module
|
10
|
-
module Core
|
11
|
-
module Http
|
12
|
-
AWS.register_autoloads(self) do
|
13
|
-
autoload :EMHttpHandler, 'em_http_handler'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# the http party handler should still be accessible from its old namespace
|
19
|
-
module Http
|
20
|
-
AWS.register_autoloads(self, 'aws/core/http') do
|
21
|
-
autoload :HTTPartyHandler, 'httparty_handler'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Load monkey patch after loading aws
|
27
|
-
require 'em_aws/core/session_signer'
|
10
|
+
module EmAws;end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'em-synchrony'
|
2
|
+
require 'em-synchrony/thread'
|
3
|
+
module AWS
|
4
|
+
# Use EM::Synchrony.sleep for all Kernel.sleep in AWS
|
5
|
+
DupKernel = Kernel
|
6
|
+
|
7
|
+
class PatchKernel
|
8
|
+
class << self
|
9
|
+
def sleep(count)
|
10
|
+
EM::Synchrony.sleep(count)
|
11
|
+
end
|
12
|
+
def method_missing(method,*args,&block)
|
13
|
+
DupKernel.send(method, *args, &block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
Kernel = PatchKernel
|
19
|
+
|
20
|
+
# Use a fiber safe mutex for Mutex in AWS
|
21
|
+
Mutex = EM::Synchrony::Thread::Mutex
|
22
|
+
end
|
data/lib/em_aws/version.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'aws'
|
3
|
+
describe AWS::Mutex do
|
4
|
+
it "should be a fiber safe mutex" do
|
5
|
+
AWS::Mutex.new.should be_kind_of(EM::Synchrony::Thread::Mutex)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should be a fiber mutex when called within AWS module" do
|
9
|
+
AWS.module_eval <<-STR
|
10
|
+
def self.mutex_new
|
11
|
+
Mutex.new
|
12
|
+
end
|
13
|
+
STR
|
14
|
+
|
15
|
+
AWS.mutex_new.should be_kind_of(EM::Synchrony::Thread::Mutex)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should not affect Mutex outside AWS" do
|
19
|
+
Mutex.new.should be_kind_of(Mutex)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe AWS::Kernel,'#sleep' do
|
24
|
+
it "should be a fiber safe sleep from with AWS module" do
|
25
|
+
EM::Synchrony.stub(:sleep).and_return("fiber safe")
|
26
|
+
AWS::Kernel.sleep(1).should eql("fiber safe")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not affect normal Kernel.sleep " do
|
30
|
+
EM::Synchrony.stub(:sleep).and_return("fiber safe")
|
31
|
+
Kernel.sleep(1).should eql(1)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should be a fiber mutex when called within AWS module" do
|
35
|
+
AWS.module_eval <<-STR
|
36
|
+
def self.sleep(time)
|
37
|
+
Kernel.sleep(time)
|
38
|
+
end
|
39
|
+
STR
|
40
|
+
EM::Synchrony.stub(:sleep).and_return("fiber safe")
|
41
|
+
AWS.sleep(0.01).should eql("fiber safe")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should not interfer with other Kernel methods" do
|
45
|
+
lambda {AWS::Kernel.rand}.should_not raise_error
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em_aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-16 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk
|
16
|
-
requirement: &
|
16
|
+
requirement: &70322481988020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70322481988020
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: em-synchrony
|
27
|
-
requirement: &
|
27
|
+
requirement: &70322481987600 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70322481987600
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: em-http-request
|
38
|
-
requirement: &
|
38
|
+
requirement: &70322481987160 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70322481987160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70322481986740 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70322481986740
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: builder
|
60
|
-
requirement: &
|
60
|
+
requirement: &70322481986320 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70322481986320
|
69
69
|
description: Adds EM-Synchrony support to AWS-SDK gem
|
70
70
|
email:
|
71
71
|
- joshmckin@gmail.com
|
@@ -83,10 +83,10 @@ files:
|
|
83
83
|
- em_aws.gemspec
|
84
84
|
- lib/aws/core/http/em_http_handler.rb
|
85
85
|
- lib/em_aws.rb
|
86
|
-
- lib/em_aws/
|
86
|
+
- lib/em_aws/patches.rb
|
87
87
|
- lib/em_aws/version.rb
|
88
88
|
- spec/em_http_handler_spec.rb
|
89
|
-
- spec/
|
89
|
+
- spec/patches_spec.rb
|
90
90
|
- spec/spec_helper.rb
|
91
91
|
homepage: ''
|
92
92
|
licenses: []
|
@@ -114,5 +114,5 @@ specification_version: 3
|
|
114
114
|
summary: Adds EM-Synchrony support to AWS-SDK gem
|
115
115
|
test_files:
|
116
116
|
- spec/em_http_handler_spec.rb
|
117
|
-
- spec/
|
117
|
+
- spec/patches_spec.rb
|
118
118
|
- spec/spec_helper.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'em-synchrony/thread'
|
2
|
-
module AWS
|
3
|
-
module Core
|
4
|
-
class SessionSigner
|
5
|
-
@create_mutex = EM::Synchrony::Thread::Mutex.new
|
6
|
-
|
7
|
-
# Monkey patch to use EM::Synchrony::Thread::Mutex instead of ::Mutex
|
8
|
-
def initialize config
|
9
|
-
@config = config
|
10
|
-
@session_mutex = EM::Synchrony::Thread::Mutex.new
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/spec/session_signer_spec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe AWS::Core::SessionSigner do
|
4
|
-
context '@create_mutex' do
|
5
|
-
it "should be a fiber safe mutex" do
|
6
|
-
AWS::Core::SessionSigner.instance_variable_get(:@create_mutex).should be_kind_of(EM::Synchrony::Thread::Mutex)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
context '@session_mutex' do
|
11
|
-
let(:config) { double("config").as_null_object }
|
12
|
-
it "should be a fiber safe mutex" do
|
13
|
-
session_signer = AWS::Core::SessionSigner.new(config)
|
14
|
-
session_signer.instance_variable_get(:@session_mutex).should be_kind_of(EM::Synchrony::Thread::Mutex)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|