thrift_client 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,15 +33,17 @@ class AbstractThriftClient
33
33
  :cached_connections => false
34
34
  }
35
35
 
36
- attr_reader :client, :client_class, :current_server, :server_list, :options, :client_methods
36
+ attr_reader :last_client, :client, :client_class, :current_server, :server_list, :options, :client_methods
37
37
 
38
38
  def initialize(client_class, servers, options = {})
39
39
  @options = DEFAULTS.merge(options)
40
40
  @options[:server_retry_period] ||= 0
41
+
41
42
  @client_class = client_class
42
43
  @server_list = Array(servers).collect do |s|
43
- Server.new(s, @options[:cached_connections])
44
+ Server.new(s, @client_class, @options)
44
45
  end.sort_by { rand }
46
+
45
47
  @current_server = @server_list.first
46
48
 
47
49
  @callbacks = {}
@@ -92,11 +94,8 @@ class AbstractThriftClient
92
94
  # call.
93
95
  def connect!
94
96
  @current_server = next_live_server
95
- @current_server.open(@options[:transport],
96
- @options[:transport_wrapper],
97
- @options[:connect_timeout],
98
- @options[:timeout])
99
- @client = @client_class.new(@options[:protocol].new(@current_server, *@options[:protocol_extra_params]))
97
+ @client = @current_server.client
98
+ @last_client = @client
100
99
  do_callbacks(:post_connect, self)
101
100
  rescue IOError, Thrift::TransportException
102
101
  disconnect!(true)
@@ -136,8 +135,20 @@ class AbstractThriftClient
136
135
  raise ThriftClient::NoServersAvailable, "No live servers in #{@server_list.inspect}."
137
136
  end
138
137
 
138
+ def ensure_socket_alignment
139
+ incomplete = true
140
+ result = yield
141
+ incomplete = false
142
+ result
143
+ # Thrift exceptions get read off the wire. We can consider them complete requests
144
+ rescue Thrift::Exception => e
145
+ incomplete = false
146
+ raise e
147
+ ensure
148
+ disconnect! if incomplete
149
+ end
150
+
139
151
  def handled_proxy(method_name, *args)
140
- disconnect! if @options[:server_max_requests] && @request_count >= @options[:server_max_requests]
141
152
  begin
142
153
  connect! unless @client
143
154
  if has_timeouts?
@@ -145,7 +156,7 @@ class AbstractThriftClient
145
156
  end
146
157
  @request_count += 1
147
158
  do_callbacks(:before_method, method_name)
148
- @client.send(method_name, *args)
159
+ ensure_socket_alignment { @client.send(method_name, *args) }
149
160
  rescue *@options[:exception_class_overrides] => e
150
161
  raise_or_default(e, method_name)
151
162
  rescue *@options[:exception_classes] => e
@@ -159,6 +170,8 @@ class AbstractThriftClient
159
170
  end
160
171
  rescue Exception => e
161
172
  raise_or_default(e, method_name)
173
+ ensure
174
+ disconnect! if @options[:server_max_requests] && @request_count >= @options[:server_max_requests]
162
175
  end
163
176
  end
164
177
 
@@ -1,14 +1,23 @@
1
1
  module ThriftHelpers
2
2
  module Connection
3
3
  class HTTP < Base
4
- def connect!
4
+ def initialize(*args)
5
+ super *args
6
+
5
7
  uri = parse_server(@server)
6
8
  @transport = Thrift::HTTPClientTransport.new(@server)
9
+ end
10
+
11
+ def connect!
7
12
  http = Net::HTTP.new(uri.host, uri.port)
8
13
  http.use_ssl = uri.scheme == "https"
9
14
  http.get(uri.path)
10
15
  end
11
16
 
17
+ def open?
18
+ true
19
+ end
20
+
12
21
  private
13
22
  def parse_server(server)
14
23
  uri = URI.parse(server)
@@ -1,14 +1,19 @@
1
1
  module ThriftHelpers
2
2
  module Connection
3
3
  class Socket < Base
4
+ def initialize(*args)
5
+ super *args
6
+
7
+ host, port = parse_server(@server)
8
+ @transport = @transport.new(host, port.to_i, @timeout)
9
+ @transport = @transport_wrapper.new(@transport) if @transport_wrapper
10
+ end
11
+
4
12
  def close
5
13
  @transport.close
6
14
  end
7
15
 
8
16
  def connect!
9
- host, port = parse_server(@server)
10
- @transport = @transport.new(*[host, port.to_i, @timeout])
11
- @transport = @transport_wrapper.new(@transport) if @transport_wrapper
12
17
  @transport.open
13
18
  end
14
19
 
@@ -4,10 +4,13 @@ module ThriftHelpers
4
4
  class Server
5
5
  class ServerMarkedDown < StandardError; end
6
6
 
7
- def initialize(connection_string, cached = true)
7
+ def initialize(connection_string, client_class, options = {})
8
8
  @connection_string = connection_string
9
- @connection = nil
10
- @cached = cached
9
+ @client_class = client_class
10
+ @options = options
11
+
12
+ @cached = @options.has_key?(:cached_connections) ? @options[:cached_connections] : true
13
+
11
14
  @marked_down_til = nil
12
15
  end
13
16
 
@@ -28,37 +31,42 @@ module ThriftHelpers
28
31
  @connection_string
29
32
  end
30
33
 
31
- def open(trans, wrap, conn_timeout, trans_timeout)
32
- if down?
33
- raise ServerMarkedDown, "marked down until #{@marked_down_til}"
34
- end
34
+ def connection
35
+ @connection ||= Connection::Factory.create(
36
+ @options[:transport], @options[:transport_wrapper],
37
+ @connection_string, @options[:connect_timeout])
38
+ end
35
39
 
36
- if @connection.nil? || (@cached && !@connection.open?)
37
- @connection = Connection::Factory.create(trans, wrap, @connection_string, conn_timeout)
38
- @connection.connect!
39
- end
40
+ def connect!
41
+ return if open?
40
42
 
41
- if wrap || trans.respond_to?(:timeout=)
42
- timeout = trans_timeout
43
- end
43
+ self.timeout = @options[:connect_timeout]
44
+ connection.connect!
45
+ self.timeout = @options[:timeout]
46
+ end
44
47
 
45
- self
48
+ def client
49
+ @client ||= begin
50
+ connect!
51
+
52
+ @client_class.new(
53
+ @options[:protocol].new(self, *@options[:protocol_extra_params]))
54
+ end
46
55
  end
47
56
 
48
57
  def open?
49
- @connection && @connection.open?
58
+ connection.open?
50
59
  end
51
60
 
52
61
  def close(teardown = false)
53
62
  if teardown || !@cached
54
- @connection.close rescue nil #TODO
55
- @connection = nil
63
+ connection.close if open?
64
+ @client = nil
56
65
  end
57
66
  end
58
67
 
59
68
  def transport
60
- return nil unless @connection
61
- @connection.transport
69
+ connection.transport
62
70
  end
63
71
 
64
72
  module TransportInterface
@@ -88,7 +96,7 @@ module ThriftHelpers
88
96
  end
89
97
 
90
98
  def timeout=(timeout)
91
- transport.timeout = timeout
99
+ transport.timeout = timeout if transport.respond_to?(:timeout=)
92
100
  end
93
101
 
94
102
  def timeout
data/lib/thrift_client.rb CHANGED
@@ -24,6 +24,7 @@ Valid optional parameters are:
24
24
  <tt>:timeout</tt>:: Specify the default timeout in seconds. Defaults to <tt>1</tt>.
25
25
  <tt>:connect_timeout</tt>:: Specify the connection timeout in seconds. Defaults to <tt>0.1</tt>.
26
26
  <tt>:timeout_overrides</tt>:: Specify additional timeouts on a per-method basis, in seconds. Only works with <tt>Thrift::BufferedTransport</tt>.
27
+ <tt>:cached_connections</tt>:: Cache connections between requests. Trades connect() costs for open sockets. Defaults to <tt>false</tt>.
27
28
  <tt>:defaults</tt>:: Specify default values to return on a per-method basis, if <tt>:raise</tt> is set to false.
28
29
  =end rdoc
29
30
 
@@ -28,18 +28,18 @@ class MultipleWorkingServersTest < Test::Unit::TestCase
28
28
  def test_server_creates_new_client_that_can_talk_to_all_servers_after_disconnect
29
29
  client = ThriftClient.new(Greeter::Client, @servers, @options)
30
30
  client.greeting("someone")
31
- internal_client = client.client
31
+ last_client = client.last_client
32
32
  client.greeting("someone")
33
- assert_equal internal_client, client.client # Sanity check
33
+ assert_equal last_client, client.last_client # Sanity check
34
34
 
35
35
  client.disconnect!
36
36
  client.greeting("someone")
37
- internal_client = client.client
37
+ last_client = client.last_client
38
38
  client.greeting("someone")
39
- assert_equal internal_client, client.client
40
- internal_client = client.client
39
+ assert_equal last_client, client.last_client
40
+ last_client = client.last_client
41
41
  client.greeting("someone")
42
- assert_equal internal_client, client.client
42
+ assert_equal last_client, client.last_client
43
43
 
44
44
  # Moves on to the second server
45
45
  assert_nothing_raised {
@@ -51,32 +51,32 @@ class MultipleWorkingServersTest < Test::Unit::TestCase
51
51
  def test_server_doesnt_max_out_after_explicit_disconnect
52
52
  client = ThriftClient.new(Greeter::Client, @servers, @options.merge(:server_max_requests => 2))
53
53
  client.greeting("someone")
54
- internal_client = client.client
54
+ last_client = client.last_client
55
55
  client.greeting("someone")
56
- assert_equal internal_client, client.client # Sanity check
56
+ assert_equal last_client, client.last_client # Sanity check
57
57
 
58
58
  client.disconnect!
59
59
 
60
60
  client.greeting("someone")
61
- internal_client = client.client
61
+ last_client = client.last_client
62
62
  client.greeting("someone")
63
- assert_equal internal_client, client.client, "ThriftClient should not have reset the internal client if the counter was reset on disconnect"
63
+ assert_equal last_client, client.last_client, "ThriftClient should not have reset the internal client if the counter was reset on disconnect"
64
64
  end
65
65
 
66
66
  def test_server_disconnect_doesnt_drop_servers_with_retry_period
67
67
  client = ThriftClient.new(Greeter::Client, @servers, @options.merge(:server_max_requests => 2, :retry_period => 1))
68
68
  3.times {
69
69
  client.greeting("someone")
70
- internal_client = client.client
70
+ last_client = client.last_client
71
71
  client.greeting("someone")
72
- assert_equal internal_client, client.client # Sanity check
72
+ assert_equal last_client, client.last_client # Sanity check
73
73
 
74
74
  client.disconnect!
75
75
 
76
76
  client.greeting("someone")
77
- internal_client = client.client
77
+ last_client = client.last_client
78
78
  client.greeting("someone")
79
- assert_equal internal_client, client.client, "ThriftClient should not have reset the internal client if the counter was reset on disconnect"
79
+ assert_equal last_client, client.last_client, "ThriftClient should not have reset the internal client if the counter was reset on disconnect"
80
80
  }
81
81
  end
82
82
 
@@ -85,28 +85,28 @@ class MultipleWorkingServersTest < Test::Unit::TestCase
85
85
  client = ThriftClient.new(Greeter::Client, @servers, @options.merge(:server_max_requests => 2))
86
86
 
87
87
  client.greeting("someone")
88
- internal_client = client.client
88
+ last_client = client.last_client
89
89
 
90
90
  client.greeting("someone")
91
- assert_equal internal_client, client.client
91
+ assert_equal last_client, client.last_client
92
92
 
93
93
  # This next call maxes out the requests for that "client" object
94
94
  # and moves on to the next.
95
95
  client.greeting("someone")
96
- assert_not_equal internal_client, new_client = client.client
96
+ assert_not_equal last_client, new_client = client.last_client
97
97
 
98
98
  # And here we should still have the same client as the last one...
99
99
  client.greeting("someone")
100
- assert_equal new_client, client.client
100
+ assert_equal new_client, client.last_client
101
101
 
102
102
  # Until we max it out, too.
103
103
  client.greeting("someone")
104
- assert_not_equal new_client, client.client
105
- assert_not_nil client.client
104
+ assert_not_equal new_client, client.last_client
105
+ assert_not_nil client.last_client
106
106
 
107
- new_new_client = client.client
107
+ new_new_client = client.last_client
108
108
  # And we should still have one server left
109
109
  client.greeting("someone")
110
- assert_equal new_new_client, client.client
110
+ assert_equal new_new_client, client.last_client
111
111
  end
112
112
  end
@@ -247,22 +247,22 @@ class ThriftClientTest < Test::Unit::TestCase
247
247
  def test_server_max_requests_with_downed_servers
248
248
  client = ThriftClient.new(Greeter::Client, @servers, @options.merge(:server_max_requests => 2, :retries => 2))
249
249
  client.greeting("someone")
250
- internal_client = client.client
250
+ last_client = client.last_client
251
251
  client.greeting("someone")
252
- assert_equal internal_client, client.client
252
+ assert_equal last_client, client.last_client
253
253
 
254
254
  # This next call maxes out the requests for that "client" object
255
255
  # and moves on to the next.
256
256
  client.greeting("someone")
257
- assert_not_equal internal_client, new_client = client.client
257
+ assert_not_equal last_client, new_client = client.last_client
258
258
 
259
259
  # And here we should still have the same client as the last one...
260
260
  client.greeting("someone")
261
- assert_equal new_client, client.client
261
+ assert_equal new_client, client.last_client
262
262
 
263
263
  # Until we max it out, too.
264
264
  client.greeting("someone")
265
- assert_not_equal internal_client, client.client
265
+ assert_not_equal last_client, client.last_client
266
266
  end
267
267
 
268
268
  private
metadata CHANGED
@@ -1,110 +1,123 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: thrift_client
3
- version: !ruby/object:Gem::Version
4
- version: 0.8.2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 57
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 8
9
+ - 3
10
+ version: 0.8.3
6
11
  platform: ruby
7
- authors:
8
- - Evan Weaver, Ryan King, Jeff Hodges
12
+ authors:
13
+ - Evan Weaver
14
+ - Ryan King
15
+ - Jeff Hodges
9
16
  autorequire:
10
17
  bindir: bin
11
18
  cert_chain: []
12
- date: 2012-09-11 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
19
+
20
+ date: 2012-11-26 00:00:00 Z
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
15
23
  name: thrift
16
- requirement: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
17
26
  none: false
18
- requirements:
27
+ requirements:
19
28
  - - ~>
20
- - !ruby/object:Gem::Version
29
+ - !ruby/object:Gem::Version
30
+ hash: 63
31
+ segments:
32
+ - 0
33
+ - 8
34
+ - 0
21
35
  version: 0.8.0
22
36
  type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: mongrel
23
40
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
41
+ requirement: &id002 !ruby/object:Gem::Requirement
25
42
  none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: 0.8.0
30
- description: A Thrift client wrapper that encapsulates some common failover behavior.
31
- email: ''
43
+ requirements:
44
+ - - "="
45
+ - !ruby/object:Gem::Version
46
+ hash: -3814261918
47
+ segments:
48
+ - 1
49
+ - 2
50
+ - 0
51
+ - pre
52
+ - 2
53
+ version: 1.2.0.pre2
54
+ type: :development
55
+ version_requirements: *id002
56
+ description:
57
+ email:
32
58
  executables: []
59
+
33
60
  extensions: []
34
- extra_rdoc_files:
35
- - CHANGELOG
36
- - LICENSE
37
- - README.rdoc
38
- - lib/thrift_client.rb
61
+
62
+ extra_rdoc_files: []
63
+
64
+ files:
39
65
  - lib/thrift_client/abstract_thrift_client.rb
40
- - lib/thrift_client/connection.rb
41
66
  - lib/thrift_client/connection/base.rb
42
67
  - lib/thrift_client/connection/factory.rb
43
68
  - lib/thrift_client/connection/http.rb
44
69
  - lib/thrift_client/connection/socket.rb
45
- - lib/thrift_client/event_machine.rb
46
- - lib/thrift_client/server.rb
47
- - lib/thrift_client/simple.rb
48
- - lib/thrift_client/thrift.rb
49
- files:
50
- - CHANGELOG
51
- - LICENSE
52
- - Manifest
53
- - README.rdoc
54
- - Rakefile
55
- - lib/thrift_client.rb
56
- - lib/thrift_client/abstract_thrift_client.rb
57
70
  - lib/thrift_client/connection.rb
58
- - lib/thrift_client/connection/base.rb
59
- - lib/thrift_client/connection/factory.rb
60
- - lib/thrift_client/connection/http.rb
61
- - lib/thrift_client/connection/socket.rb
62
71
  - lib/thrift_client/event_machine.rb
63
72
  - lib/thrift_client/server.rb
64
73
  - lib/thrift_client/simple.rb
65
74
  - lib/thrift_client/thrift.rb
75
+ - lib/thrift_client.rb
66
76
  - test/greeter/greeter.rb
67
- - test/greeter/greeter.thrift
68
77
  - test/greeter/server.rb
69
78
  - test/multiple_working_servers_test.rb
70
79
  - test/simple_test.rb
71
80
  - test/test_helper.rb
72
81
  - test/thrift_client_http_test.rb
73
82
  - test/thrift_client_test.rb
74
- - thrift_client.gemspec
75
- homepage: http://fauna.github.com/fauna/thrift_client/
83
+ homepage: https://github.com/twitter/thrift_client
76
84
  licenses: []
85
+
77
86
  post_install_message:
78
- rdoc_options:
79
- - --line-numbers
80
- - --inline-source
81
- - --title
82
- - Thrift_client
83
- - --main
84
- - README.rdoc
85
- require_paths:
87
+ rdoc_options: []
88
+
89
+ require_paths:
86
90
  - lib
87
- required_ruby_version: !ruby/object:Gem::Requirement
91
+ required_ruby_version: !ruby/object:Gem::Requirement
88
92
  none: false
89
- requirements:
90
- - - ! '>='
91
- - !ruby/object:Gem::Version
92
- version: '0'
93
- required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
101
  none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
98
- version: '0.8'
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
99
109
  requirements: []
100
- rubyforge_project: fauna
101
- rubygems_version: 1.8.23
110
+
111
+ rubyforge_project:
112
+ rubygems_version: 1.8.24
102
113
  signing_key:
103
114
  specification_version: 3
104
115
  summary: A Thrift client wrapper that encapsulates some common failover behavior.
105
- test_files:
106
- - test/thrift_client_http_test.rb
107
- - test/thrift_client_test.rb
108
- - test/test_helper.rb
116
+ test_files:
117
+ - test/greeter/greeter.rb
118
+ - test/greeter/server.rb
109
119
  - test/multiple_working_servers_test.rb
110
120
  - test/simple_test.rb
121
+ - test/test_helper.rb
122
+ - test/thrift_client_http_test.rb
123
+ - test/thrift_client_test.rb
data/CHANGELOG DELETED
@@ -1,74 +0,0 @@
1
- v0.8.2 Connect errors now mark servers down for _server_retry_period_.
2
- Added support for cached connections to amortize connection costs.
3
-
4
- v0.8.1 Fixed permissions?
5
-
6
- v0.8.0 Update to thrift 0.8.0
7
-
8
- v0.7.1 Added support for :before_method and :on_exception callback types.
9
- Added support for registering multiple callbacks of a given type.
10
-
11
- v0.7.0 Updated thrift gem dependency to 0.7.0
12
-
13
- v0.6.3 Document the :connect_timeout option.
14
- Add support for specifying client-side timeouts when using FramedTransport
15
- set transport timeout after connection is established
16
- Add a method `add_callback` allowing a client to register a block that is invoked at a certain event.
17
- Fixup socket timeouts.
18
-
19
-
20
-
21
- v0.6.2 Remove lingering thrift v0.5.0 reference.
22
-
23
- v0.6.1 Add connect timeout. Bump thrift dependency to ~> v0.6.0.
24
-
25
- v0.6.0 Fix bug where we'd try to mark the current server down when we didn't have a current server.
26
- Upgrade to thrift 0.5.
27
-
28
- v0.5.0 Add support for wrapping exceptions, so that Thrift::Foo can become Greeter::Foo.
29
- Make server_retry_period work the way you expect.
30
- Better bookkeeping around marking servers as dead.
31
-
32
- v0.4.7 fix thrift gem dependency
33
-
34
- v0.4.6 Add support for oneway methods.
35
-
36
- v0.4.5. Fix broken retries.
37
-
38
- v0.4.4. Default to 0 retries rather than the number of servers.
39
-
40
- v0.4.3. Bug fixes: handle_exception could be called more than once. Integer types are read signed.
41
-
42
- v0.4.2. Allow per-method overrides of retries. Fix several bugs with EventMachine.
43
-
44
- v0.4.1. Making ThriftClient decoratable. Able to add new functionality a class definition.
45
-
46
- v0.4.0. Add new EventMachine transport. This requires two layers of transport
47
- configurability:
48
- options[:transport] for EventMachine or Socket transports
49
- options[:transport_wrapper] for optional Buffered or Framed Transport.
50
- Clients will need to update their options to ensure they don't conflict with this change. (mperham)
51
- Revert global timeouts. (ryanking)
52
- Add support for HTTPClientTransport (Chris Sepic)
53
-
54
- v0.3.3. Allow for a timeout over all requests in a call.
55
-
56
- v0.3.2. Fix connection close bug (nkallen, mattknox).
57
-
58
- v0.3.1. Add ability to reset connection after N requests.
59
-
60
- v0.3. Change default timeout semantics; hash default was too sneaky. Fix bug.
61
-
62
- v0.2.2. Fix connect bug.
63
-
64
- v0.2.1. Don't turn off strict_read by default; allow override.
65
-
66
- v0.2. Add ThriftClient::Simple (Robey).
67
-
68
- v0.1.3. Define methods explicitly.
69
-
70
- v0.1.2. Support default responses.
71
-
72
- v0.1.1. Support server_retry_period.
73
-
74
- v0.1. First release.
data/LICENSE DELETED
@@ -1,202 +0,0 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright [yyyy] [name of copyright owner]
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
data/Manifest DELETED
@@ -1,25 +0,0 @@
1
- CHANGELOG
2
- LICENSE
3
- Manifest
4
- README.rdoc
5
- Rakefile
6
- lib/thrift_client.rb
7
- lib/thrift_client/abstract_thrift_client.rb
8
- lib/thrift_client/connection.rb
9
- lib/thrift_client/connection/base.rb
10
- lib/thrift_client/connection/factory.rb
11
- lib/thrift_client/connection/http.rb
12
- lib/thrift_client/connection/socket.rb
13
- lib/thrift_client/event_machine.rb
14
- lib/thrift_client/server.rb
15
- lib/thrift_client/simple.rb
16
- lib/thrift_client/thrift.rb
17
- test/greeter/greeter.rb
18
- test/greeter/greeter.thrift
19
- test/greeter/server.rb
20
- test/multiple_working_servers_test.rb
21
- test/simple_test.rb
22
- test/test_helper.rb
23
- test/thrift_client_http_test.rb
24
- test/thrift_client_test.rb
25
- thrift_client.gemspec
data/README.rdoc DELETED
@@ -1,60 +0,0 @@
1
-
2
- thrift_client
3
-
4
- A Thrift client wrapper that encapsulates some common failover behavior.
5
-
6
- == License
7
-
8
- Copyright 2009 Twitter, Inc. See included LICENSE file.
9
-
10
- The public certificate for this gem is here[http://blog.evanweaver.com/files/evan_weaver-original-public_cert.pem].
11
-
12
- == Features
13
-
14
- * Transparent connection management
15
- * Configurable failover and retry backoff
16
- * Ruby 1.9 compatibility
17
- * ThriftClient::Simple class, for working without generated bindings.
18
-
19
- The Github source repository is {here}[http://github.com/fauna/thrift_client/]. Patches and contributions are very welcome.
20
-
21
- == Usage
22
-
23
- Instantiate a client:
24
-
25
- client = ThriftClient.new(CassandraRb::Client, '127.0.0.1:9160', :retries => 2)
26
-
27
- You can then make calls to the server via the <tt>client</tt> instance as if was your internal Thrift client. The connection will be opened lazily and methods will be proxied through.
28
-
29
- client.get_string_list_property("keyspaces")
30
-
31
- On failures, the client will try the remaining servers in the list before giving up. See ThriftClient for more.
32
-
33
- == Timeouts
34
-
35
- Timeouts are enforced per-try, so if you have a timeout of n and do m retries, the total time it could take is n*m.
36
-
37
- == Connection Handling
38
-
39
- The library will shuffle the host list then work its way down this list, only moving to the next host if it received an error or you've doing more than server_max_requests requests with that host (defaults to 0 which means there's no limit).
40
-
41
- Servers that throw an error get marked as dead and will only be retried every server_retry_period seconds (at that time all dead servers are retried, no matter long they've been marked as dead).
42
-
43
- == Installation
44
-
45
- You need Ruby 1.8 or 1.9. If you have those, just run:
46
-
47
- sudo gem install thrift_client
48
-
49
- == Contributing
50
-
51
- To contribute changes:
52
-
53
- 1. Fork the project
54
- 2. make your change, adding tests
55
- 3. send a pull request to fauna and ryanking
56
-
57
- == Reporting problems
58
-
59
- The Github issue tracker is {here}[http://github.com/fauna/thrift_client/issues].
60
-
data/Rakefile DELETED
@@ -1,14 +0,0 @@
1
-
2
- require 'rubygems'
3
- require 'echoe'
4
-
5
- Echoe.new("thrift_client") do |p|
6
- p.author = ["Evan Weaver", "Ryan King", "Jeff Hodges"]
7
- p.project = "fauna"
8
- p.summary = "A Thrift client wrapper that encapsulates some common failover behavior."
9
- p.rubygems_version = ">= 0.8"
10
- p.dependencies = ['thrift ~>0.8.0']
11
- p.ignore_pattern = /^(vendor\/thrift)/
12
- p.rdoc_pattern = /^(lib|bin|tasks|ext)|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/
13
- p.spec_pattern = "spec/*_spec.rb"
14
- end
@@ -1,4 +0,0 @@
1
- service Greeter {
2
- string greeting(1:string name)
3
- oneway void yo(1:string name)
4
- }
@@ -1,33 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = "thrift_client"
5
- s.version = "0.8.2"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0.8") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Evan Weaver, Ryan King, Jeff Hodges"]
9
- s.date = "2012-09-11"
10
- s.description = "A Thrift client wrapper that encapsulates some common failover behavior."
11
- s.email = ""
12
- s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.rdoc", "lib/thrift_client.rb", "lib/thrift_client/abstract_thrift_client.rb", "lib/thrift_client/connection.rb", "lib/thrift_client/connection/base.rb", "lib/thrift_client/connection/factory.rb", "lib/thrift_client/connection/http.rb", "lib/thrift_client/connection/socket.rb", "lib/thrift_client/event_machine.rb", "lib/thrift_client/server.rb", "lib/thrift_client/simple.rb", "lib/thrift_client/thrift.rb"]
13
- s.files = ["CHANGELOG", "LICENSE", "Manifest", "README.rdoc", "Rakefile", "lib/thrift_client.rb", "lib/thrift_client/abstract_thrift_client.rb", "lib/thrift_client/connection.rb", "lib/thrift_client/connection/base.rb", "lib/thrift_client/connection/factory.rb", "lib/thrift_client/connection/http.rb", "lib/thrift_client/connection/socket.rb", "lib/thrift_client/event_machine.rb", "lib/thrift_client/server.rb", "lib/thrift_client/simple.rb", "lib/thrift_client/thrift.rb", "test/greeter/greeter.rb", "test/greeter/greeter.thrift", "test/greeter/server.rb", "test/multiple_working_servers_test.rb", "test/simple_test.rb", "test/test_helper.rb", "test/thrift_client_http_test.rb", "test/thrift_client_test.rb", "thrift_client.gemspec"]
14
- s.homepage = "http://fauna.github.com/fauna/thrift_client/"
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Thrift_client", "--main", "README.rdoc"]
16
- s.require_paths = ["lib"]
17
- s.rubyforge_project = "fauna"
18
- s.rubygems_version = "1.8.23"
19
- s.summary = "A Thrift client wrapper that encapsulates some common failover behavior."
20
- s.test_files = ["test/thrift_client_http_test.rb", "test/thrift_client_test.rb", "test/test_helper.rb", "test/multiple_working_servers_test.rb", "test/simple_test.rb"]
21
-
22
- if s.respond_to? :specification_version then
23
- s.specification_version = 3
24
-
25
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency(%q<thrift>, ["~> 0.8.0"])
27
- else
28
- s.add_dependency(%q<thrift>, ["~> 0.8.0"])
29
- end
30
- else
31
- s.add_dependency(%q<thrift>, ["~> 0.8.0"])
32
- end
33
- end