thrift_rack 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 773b0e6d88aa7f1985166dc435f1a86e060a37a9
4
- data.tar.gz: 6086c1097e403a8d0b9a7905a714f2f36e2562e8
3
+ metadata.gz: 3112a7bb184974829cabffede052e726282e26b6
4
+ data.tar.gz: f465453942e1f42e97d056c93c094f66a751af42
5
5
  SHA512:
6
- metadata.gz: 2846261de0e9c65282acd06787d01cb167a2523afa544cf395ad089b643769c5c138e033cf1b0eac327ca75502b416d07860867da673711982809ed5e9490a0d
7
- data.tar.gz: 933c12c2164c69cd3dcf42507c81edfe0e882435139ebd87620826fabaa875dd4eb950477f855e57dfcc90f0ff92803951180b75decb196defd6b4090e088759
6
+ metadata.gz: 59862634376d053336d96e7d36c4af4286a7802764ebb638d90e5aaa0b0fb261e1fbdd78d9bfaf03335f377b9cb3d3a22d4951b0e1cedf5d56f63696c7c69d68
7
+ data.tar.gz: eeaa115cc611531979398ff94ff098eba40e58aea256dde0e1f0707c7c88d345fb210fda06f8712aa10ba26f7fde2f6ad32a906e0d2af82d12d0e83e1c635d00
data/Gemfile.lock CHANGED
@@ -1,18 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thrift_rack (0.1.9)
5
- connection_pool (~> 2.2.1)
6
- excon (~> 0.62.0)
4
+ thrift_rack (0.2.0)
7
5
  rack (>= 2.0)
8
6
  thrift (~> 0.10.0)
7
+ typhoeus (> 1.1)
9
8
 
10
9
  GEM
11
10
  remote: https://rubygems.org/
12
11
  specs:
13
12
  coderay (1.1.2)
14
- connection_pool (2.2.1)
15
- excon (0.62.0)
13
+ ethon (0.11.0)
14
+ ffi (>= 1.3.0)
15
+ ffi (1.9.23)
16
16
  method_source (0.9.0)
17
17
  pry (0.11.3)
18
18
  coderay (~> 1.1.0)
@@ -20,6 +20,8 @@ GEM
20
20
  rack (2.0.5)
21
21
  rake (10.5.0)
22
22
  thrift (0.10.0.0)
23
+ typhoeus (1.3.0)
24
+ ethon (>= 0.9.0)
23
25
 
24
26
  PLATFORMS
25
27
  ruby
data/lib/thrift_rack.rb CHANGED
@@ -5,7 +5,6 @@ require "thrift_rack/client"
5
5
  require 'thrift_rack/ping'
6
6
  require 'thrift_rack/format_check'
7
7
  require 'thrift_rack/http_client_transport'
8
- require 'thrift_rack/excon_pool'
9
8
 
10
9
  require 'rack'
11
10
  require 'thrift'
@@ -4,7 +4,7 @@ class ThriftRack
4
4
  def initialize(url, client_klass, request_id = nil)
5
5
  @request_id = request_id || "no-request"
6
6
  @url = url
7
- @transport = ThriftRack::HttpClientTransport.new(ThriftRack::ExconPool.get(url), URI(url).path)
7
+ @transport = ThriftRack::HttpClientTransport.new(url)
8
8
  protocol = protocol_factory.get_protocol(@transport)
9
9
  @client = client_klass.new(protocol)
10
10
  end
@@ -55,15 +55,7 @@ class ThriftRack
55
55
  end
56
56
 
57
57
  class << self
58
- attr_accessor :app_name, :pool_size, :pool_timeout
59
-
60
- def pool_size
61
- @pool_size || 128
62
- end
63
-
64
- def pool_timeout
65
- @pool_timeout || 3
66
- end
58
+ attr_accessor :app_name
67
59
  end
68
60
  end
69
61
  end
@@ -1,15 +1,13 @@
1
1
  require 'thrift'
2
- require 'excon'
3
2
  require "stringio"
4
- Excon.defaults[:ssl_verify_peer] = false
3
+ require 'typhoeus'
5
4
  class ThriftRack
6
5
  class HttpClientTransport < Thrift::BaseTransport
7
6
  class RespCodeError < StandardError; end
8
- def initialize(client, path, opts = {})
7
+ def initialize(url, opts = {})
9
8
  @headers = {'Content-Type' => 'application/x-thrift'}
10
9
  @outbuf = Thrift::Bytes.empty_byte_buffer
11
- @client = client
12
- @path = path
10
+ @url = url
13
11
  end
14
12
 
15
13
  def open?; true end
@@ -22,9 +20,9 @@ class ThriftRack
22
20
 
23
21
 
24
22
  def flush
25
- resp = @client.post(path: @path, body: @outbuf, headers: @headers, idempotent: true)
23
+ resp = Typhoeus.post(@url, body: @outbuf, headers: @headers, ssl_verifypeer: false)
26
24
  data = resp.body
27
- raise RespCodeError.new("#{resp.status} on #{@path} with body #{data}") unless resp.status == 200
25
+ raise RespCodeError.new("#{resp.code} on #{@url} with body #{data}") unless resp.code == 200
28
26
  data = Thrift::Bytes.force_binary_encoding(data)
29
27
  @inbuf = StringIO.new data
30
28
  ensure
@@ -1,3 +1,3 @@
1
1
  class ThriftRack
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
data/thrift_rack.gemspec CHANGED
@@ -23,8 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency "rack", ">= 2.0"
25
25
  spec.add_dependency "thrift", '~> 0.10.0'
26
- spec.add_dependency "excon", "~> 0.62.0"
27
- spec.add_dependency "connection_pool", "~> 2.2.1"
26
+ spec.add_dependency 'typhoeus', '> 1.1'
28
27
 
29
28
  spec.add_development_dependency "bundler", "~> 1.16"
30
29
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thrift_rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - xuxiangyang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-03 00:00:00.000000000 Z
11
+ date: 2018-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -39,33 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.10.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: excon
42
+ name: typhoeus
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.62.0
47
+ version: '1.1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.62.0
55
- - !ruby/object:Gem::Dependency
56
- name: connection_pool
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 2.2.1
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
52
+ - - ">"
67
53
  - !ruby/object:Gem::Version
68
- version: 2.2.1
54
+ version: '1.1'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: bundler
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -126,7 +112,6 @@ files:
126
112
  - lib/config.ru
127
113
  - lib/thrift_rack.rb
128
114
  - lib/thrift_rack/client.rb
129
- - lib/thrift_rack/excon_pool.rb
130
115
  - lib/thrift_rack/format_check.rb
131
116
  - lib/thrift_rack/http_client_transport.rb
132
117
  - lib/thrift_rack/logger.rb
@@ -1,16 +0,0 @@
1
- require 'connection_pool'
2
- class ThriftRack
3
- class ExconPool
4
- class << self
5
- def pool
6
- @pool ||= {}
7
- end
8
-
9
- def get(url)
10
- @pool ||= {}
11
- uri = URI(url)
12
- @pool["#{uri.host}:#{uri.port}"] ||= ConnectionPool::Wrapper.new(size: ThriftRack::Client.pool_size, timeout: ThriftRack::Client.pool_timeout) {Excon.new("#{uri.scheme}://#{uri.host}:#{uri.port}", persistent: true)}
13
- end
14
- end
15
- end
16
- end