thrift_client 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,6 +35,17 @@ class AbstractThriftClient
35
35
 
36
36
  attr_reader :last_client, :client, :client_class, :current_server, :server_list, :options, :client_methods
37
37
 
38
+ def self.create_wrapped_exception_classes(client_class, wrapped_exception_classes = DEFAULT_WRAPPED_ERRORS)
39
+ wrapped_exception_classes.map do |exception_klass|
40
+ name = exception_klass.to_s.split('::').last
41
+ begin
42
+ client_class.const_get(name)
43
+ rescue NameError
44
+ client_class.const_set(name, Class.new(exception_klass))
45
+ end
46
+ end
47
+ end
48
+
38
49
  def initialize(client_class, servers, options = {})
39
50
  @options = DEFAULTS.merge(options)
40
51
  @options[:server_retry_period] ||= 0
@@ -55,14 +66,7 @@ class AbstractThriftClient
55
66
  end
56
67
  end
57
68
  @request_count = 0
58
- @options[:wrapped_exception_classes].each do |exception_klass|
59
- name = exception_klass.to_s.split('::').last
60
- begin
61
- @client_class.const_get(name)
62
- rescue NameError
63
- @client_class.const_set(name, Class.new(exception_klass))
64
- end
65
- end
69
+ self.class.create_wrapped_exception_classes(@client_class, @options[:wrapped_exception_classes])
66
70
  end
67
71
 
68
72
  # Adds a callback that will be invoked at a certain time. The valid callback types are:
@@ -33,8 +33,8 @@ module Greeter
33
33
  uri = URI.parse(uri)
34
34
  handler = Greeter::Handler.new
35
35
  processor = Greeter::Processor.new(handler)
36
- path = uri.path[1..-1]
37
- @server = Thrift::MongrelHTTPServer.new(processor, :port => uri.port, :ip => uri.host, :path => path)
36
+ path = uri.path
37
+ @server = Thrift::ThinHTTPServer.new(processor, :port => uri.port, :ip => uri.host, :path => path)
38
38
  end
39
39
 
40
40
  def serve
@@ -1,5 +1,4 @@
1
1
  require File.expand_path('test_helper.rb', File.dirname(__FILE__))
2
- require "thrift/server/mongrel_http_server"
3
2
 
4
3
  class ThriftClientHTTPTest < Test::Unit::TestCase
5
4
 
@@ -14,7 +13,7 @@ class ThriftClientHTTPTest < Test::Unit::TestCase
14
13
  end
15
14
  # Need to give the child process a moment to open the listening socket or
16
15
  # we get occasional "could not connect" errors in tests.
17
- sleep 0.05
16
+ sleep 0.20
18
17
  end
19
18
 
20
19
  def teardown
@@ -26,6 +26,13 @@ class ThriftClientTest < Test::Unit::TestCase
26
26
  assert_equal "<ThriftClient(Greeter::Client) @current_server=127.0.0.1:1463>", client.inspect
27
27
  end
28
28
 
29
+ def test_create_wrapped_exception_classes
30
+ client = Module.new
31
+ ThriftClient.create_wrapped_exception_classes(client, [Thrift::TransportException])
32
+ assert client.const_defined?(:TransportException)
33
+ assert client.const_get(:TransportException).new.is_a?(Thrift::TransportException)
34
+ end
35
+
29
36
  def test_live_server
30
37
  assert_nothing_raised do
31
38
  ThriftClient.new(Greeter::Client, @servers.last, @options).greeting("someone")
metadata CHANGED
@@ -1,81 +1,88 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: thrift_client
3
- version: !ruby/object:Gem::Version
4
- hash: 63
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 9
9
- - 2
10
- version: 0.9.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Evan Weaver
14
9
  - Ryan King
15
10
  - Jeff Hodges
16
11
  autorequire:
17
12
  bindir: bin
18
13
  cert_chain: []
19
-
20
- date: 2013-04-11 00:00:00 Z
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
14
+ date: 2014-08-27 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
23
17
  name: thrift
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
26
19
  none: false
27
- requirements:
20
+ requirements:
28
21
  - - ~>
29
- - !ruby/object:Gem::Version
30
- hash: 59
31
- segments:
32
- - 0
33
- - 9
34
- - 0
22
+ - !ruby/object:Gem::Version
35
23
  version: 0.9.0
36
24
  type: :runtime
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: 0.9.0
32
+ - !ruby/object:Gem::Dependency
39
33
  name: rake
34
+ requirement: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
40
41
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: rack
50
+ requirement: !ruby/object:Gem::Requirement
42
51
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- hash: 3
47
- segments:
48
- - 0
49
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
50
56
  type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: mongrel
54
57
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ - !ruby/object:Gem::Dependency
65
+ name: thin
66
+ requirement: !ruby/object:Gem::Requirement
56
67
  none: false
57
- requirements:
58
- - - "="
59
- - !ruby/object:Gem::Version
60
- hash: 3622799061
61
- segments:
62
- - 1
63
- - 2
64
- - 0
65
- - pre
66
- - 2
67
- version: 1.2.0.pre2
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
68
72
  type: :development
69
- version_requirements: *id003
73
+ prerelease: false
74
+ version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
70
80
  description:
71
81
  email:
72
82
  executables: []
73
-
74
83
  extensions: []
75
-
76
84
  extra_rdoc_files: []
77
-
78
- files:
85
+ files:
79
86
  - lib/thrift_client/abstract_thrift_client.rb
80
87
  - lib/thrift_client/connection/base.rb
81
88
  - lib/thrift_client/connection/factory.rb
@@ -95,39 +102,31 @@ files:
95
102
  - test/thrift_client_http_test.rb
96
103
  - test/thrift_client_test.rb
97
104
  homepage: https://github.com/twitter/thrift_client
98
- licenses: []
99
-
105
+ licenses:
106
+ - Apache 2.0
100
107
  post_install_message:
101
108
  rdoc_options: []
102
-
103
- require_paths:
109
+ require_paths:
104
110
  - lib
105
- required_ruby_version: !ruby/object:Gem::Requirement
111
+ required_ruby_version: !ruby/object:Gem::Requirement
106
112
  none: false
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- hash: 3
111
- segments:
112
- - 0
113
- version: "0"
114
- required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
118
  none: false
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- hash: 3
120
- segments:
121
- - 0
122
- version: "0"
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
123
  requirements: []
124
-
125
124
  rubyforge_project:
126
- rubygems_version: 1.8.15
125
+ rubygems_version: 1.8.23
127
126
  signing_key:
128
127
  specification_version: 3
129
128
  summary: A Thrift client wrapper that encapsulates some common failover behavior.
130
- test_files:
129
+ test_files:
131
130
  - test/greeter/greeter.rb
132
131
  - test/greeter/server.rb
133
132
  - test/multiple_working_servers_test.rb