gateway 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/gateway.gemspec +80 -0
- data/lib/gateway/connection.rb +4 -4
- data/lib/gateway/feature/categorize_error.rb +9 -3
- metadata +18 -17
data/README.rdoc
CHANGED
@@ -10,7 +10,7 @@ This gem provides a `Gateway::Base` class for other connection types to be built
|
|
10
10
|
* Automatic retry
|
11
11
|
* performance logging
|
12
12
|
* Newrelic instrumentation. ( If newrelic is loaded. )
|
13
|
-
|
13
|
+
* Designed specifically for multi-threaded usage and is completely thread safe.
|
14
14
|
|
15
15
|
== Contributing to gateway
|
16
16
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/gateway.gemspec
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "gateway"
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Aaron Qian"]
|
12
|
+
s.date = "2012-02-15"
|
13
|
+
s.description = " Opinionated Generic IO Connection Manager "
|
14
|
+
s.email = "aq1018@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"gateway.gemspec",
|
28
|
+
"lib/gateway.rb",
|
29
|
+
"lib/gateway/base.rb",
|
30
|
+
"lib/gateway/connection.rb",
|
31
|
+
"lib/gateway/connection/pool.rb",
|
32
|
+
"lib/gateway/connection/single.rb",
|
33
|
+
"lib/gateway/connection/thread_local.rb",
|
34
|
+
"lib/gateway/errors.rb",
|
35
|
+
"lib/gateway/feature/categorize_error.rb",
|
36
|
+
"lib/gateway/feature/error_handle.rb",
|
37
|
+
"lib/gateway/feature/new_relic.rb",
|
38
|
+
"lib/gateway/feature/performance.rb",
|
39
|
+
"lib/gateway/feature/retry.rb",
|
40
|
+
"lib/gateway/feature/timeout.rb",
|
41
|
+
"spec/gateway_spec.rb",
|
42
|
+
"spec/spec_helper.rb"
|
43
|
+
]
|
44
|
+
s.homepage = "http://github.com/aq1018/gateway"
|
45
|
+
s.licenses = ["MIT"]
|
46
|
+
s.require_paths = ["lib"]
|
47
|
+
s.rubygems_version = "1.8.10"
|
48
|
+
s.summary = "Opinionated Generic IO Connection Manager"
|
49
|
+
|
50
|
+
if s.respond_to? :specification_version then
|
51
|
+
s.specification_version = 3
|
52
|
+
|
53
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
54
|
+
s.add_runtime_dependency(%q<activesupport>, ["~> 3.0"])
|
55
|
+
s.add_runtime_dependency(%q<resource_pool>, [">= 0.2.0"])
|
56
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
57
|
+
s.add_development_dependency(%q<yard>, ["~> 0.7"])
|
58
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
59
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
60
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<activesupport>, ["~> 3.0"])
|
63
|
+
s.add_dependency(%q<resource_pool>, [">= 0.2.0"])
|
64
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
65
|
+
s.add_dependency(%q<yard>, ["~> 0.7"])
|
66
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
67
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
68
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
69
|
+
end
|
70
|
+
else
|
71
|
+
s.add_dependency(%q<activesupport>, ["~> 3.0"])
|
72
|
+
s.add_dependency(%q<resource_pool>, [">= 0.2.0"])
|
73
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
74
|
+
s.add_dependency(%q<yard>, ["~> 0.7"])
|
75
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
76
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
77
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
data/lib/gateway/connection.rb
CHANGED
@@ -4,6 +4,10 @@ module Gateway
|
|
4
4
|
include ThreadLocal
|
5
5
|
include Pool
|
6
6
|
|
7
|
+
def purge_current_connection!
|
8
|
+
send "purge_current_connection_from_#{connection_type}!"
|
9
|
+
end
|
10
|
+
|
7
11
|
protected
|
8
12
|
|
9
13
|
def connect
|
@@ -18,10 +22,6 @@ module Gateway
|
|
18
22
|
raise "Abstract Method"
|
19
23
|
end
|
20
24
|
|
21
|
-
def purge_current_connection!
|
22
|
-
send "purge_current_connection_from_#{connection_type}!"
|
23
|
-
end
|
24
|
-
|
25
25
|
def connection_type
|
26
26
|
@connection_type ||= (options[:connection_type] || :thread_local)
|
27
27
|
end
|
@@ -14,24 +14,27 @@ module Gateway
|
|
14
14
|
protected
|
15
15
|
|
16
16
|
def errors_for(action, error_category)
|
17
|
+
action = action.to_s
|
17
18
|
cat = self.error_catalog[error_category]
|
18
19
|
return [] if cat.blank?
|
19
20
|
|
20
21
|
errors = cat[action] ? cat[action][:errors] : []
|
21
|
-
default_errors = cat[
|
22
|
+
default_errors = cat['all'][:errors] || []
|
22
23
|
errors + default_errors
|
23
24
|
end
|
24
25
|
|
25
26
|
def error_callbacks_for(action, error_category)
|
27
|
+
action = action.to_s
|
26
28
|
cat = self.error_catalog[error_category]
|
27
29
|
return [] if cat.blank?
|
28
30
|
|
29
31
|
lambdas = cat[action] ? cat[action][:lambdas] : []
|
30
|
-
default_lambdas = cat[
|
32
|
+
default_lambdas = cat['all'][:lambdas] || []
|
31
33
|
lambdas + default_lambdas
|
32
34
|
end
|
33
35
|
|
34
36
|
def run_callbacks_for(action, error_category)
|
37
|
+
action = action.to_s
|
35
38
|
error_callbacks_for(action, error_category).each do |cb|
|
36
39
|
cb.call self
|
37
40
|
end
|
@@ -63,7 +66,10 @@ module Gateway
|
|
63
66
|
errors = params.flatten
|
64
67
|
|
65
68
|
actions = [opt[:for]].flatten.compact
|
66
|
-
actions = [
|
69
|
+
actions = ['all'] if actions.blank?
|
70
|
+
|
71
|
+
# convert actions to string
|
72
|
+
actions.map!{ |action| action.to_s }
|
67
73
|
|
68
74
|
categories = [opt[:as]].flatten.compact
|
69
75
|
categories = error_categories if categories.blank?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gateway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
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-02-
|
12
|
+
date: 2012-02-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &23019720 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *23019720
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: resource_pool
|
27
|
-
requirement: &
|
27
|
+
requirement: &23018980 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.2.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *23018980
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &23018260 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.8.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *23018260
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yard
|
49
|
-
requirement: &
|
49
|
+
requirement: &23017220 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0.7'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *23017220
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rdoc
|
60
|
-
requirement: &
|
60
|
+
requirement: &23223600 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '3.12'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *23223600
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
|
-
requirement: &
|
71
|
+
requirement: &23222780 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.0.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *23222780
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: jeweler
|
82
|
-
requirement: &
|
82
|
+
requirement: &23221940 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: 1.8.3
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *23221940
|
91
91
|
description: ! ' Opinionated Generic IO Connection Manager '
|
92
92
|
email: aq1018@gmail.com
|
93
93
|
executables: []
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- README.rdoc
|
104
104
|
- Rakefile
|
105
105
|
- VERSION
|
106
|
+
- gateway.gemspec
|
106
107
|
- lib/gateway.rb
|
107
108
|
- lib/gateway/base.rb
|
108
109
|
- lib/gateway/connection.rb
|
@@ -133,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
134
|
version: '0'
|
134
135
|
segments:
|
135
136
|
- 0
|
136
|
-
hash:
|
137
|
+
hash: 2883031289756242094
|
137
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
139
|
none: false
|
139
140
|
requirements:
|