thrift_rack 0.1.7 → 0.1.8
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e40a0428d460166190b44aff02be27ee45ee56f6
|
4
|
+
data.tar.gz: 36b6e37828a570654e93b1659e098e0ea38e01f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d0703322c68962056f3bb648390d031d6cb58e4a9bff4f6a202ac0e025a32dcbb382ed3e61b346f39e338dbf94d8e7d15dfcba96d79064710e83aaa404fd3d9
|
7
|
+
data.tar.gz: 008c47be652f5609dacf18b036a7b0dcb32ce645e3743223b7836952f2cb71dfeea4439e178295355cc69762704881e2d1e8fcda9eb6064341c0cca977e08655
|
data/lib/thrift_rack/client.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
require 'thrift'
|
2
1
|
require 'securerandom'
|
3
2
|
class ThriftRack
|
4
3
|
class Client
|
5
4
|
def initialize(url, client_klass, request_id = nil)
|
6
5
|
@request_id = request_id || "no-request"
|
7
6
|
@url = url
|
8
|
-
@transport = ThriftRack::
|
7
|
+
@transport = ThriftRack::HttpClientTransport.new(ThriftRack::ExconPool.get(url), URI(url).path)
|
9
8
|
protocol = protocol_factory.get_protocol(@transport)
|
10
9
|
@client = client_klass.new(protocol)
|
11
10
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'connection_pool'
|
2
2
|
class ThriftRack
|
3
|
-
class
|
3
|
+
class ExconPool
|
4
4
|
class << self
|
5
5
|
def pool
|
6
6
|
@pool ||= {}
|
@@ -9,7 +9,7 @@ class ThriftRack
|
|
9
9
|
def get(url)
|
10
10
|
@pool ||= {}
|
11
11
|
uri = URI(url)
|
12
|
-
@pool["#{uri.host}:#{uri.port}"] ||= ConnectionPool::Wrapper.new(size: ThriftRack::Client.pool_size, timeout: ThriftRack::Client.pool_timeout) {
|
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
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -1,15 +1,27 @@
|
|
1
|
+
require 'thrift'
|
1
2
|
require 'excon'
|
2
3
|
require "stringio"
|
3
4
|
Excon.defaults[:ssl_verify_peer] = false
|
4
5
|
class ThriftRack
|
5
|
-
class
|
6
|
-
def initialize(
|
7
|
-
|
8
|
-
@
|
6
|
+
class HttpClientTransport < Thrift::BaseTransport
|
7
|
+
def initialize(client, path, opts = {})
|
8
|
+
@headers = {'Content-Type' => 'application/x-thrift'}
|
9
|
+
@outbuf = Thrift::Bytes.empty_byte_buffer
|
10
|
+
@client = client
|
11
|
+
@path = path
|
9
12
|
end
|
10
13
|
|
14
|
+
def open?; true end
|
15
|
+
def read(sz); @inbuf.read sz end
|
16
|
+
def write(buf); @outbuf << Thrift::Bytes.force_binary_encoding(buf) end
|
17
|
+
|
18
|
+
def add_headers(headers)
|
19
|
+
@headers = @headers.merge(headers)
|
20
|
+
end
|
21
|
+
|
22
|
+
|
11
23
|
def flush
|
12
|
-
resp = @client.post(body: @outbuf, headers: @headers, idempotent: true)
|
24
|
+
resp = @client.post(path: @path, body: @outbuf, headers: @headers, idempotent: true)
|
13
25
|
data = resp.body
|
14
26
|
data = Thrift::Bytes.force_binary_encoding(data)
|
15
27
|
@inbuf = StringIO.new data
|
data/lib/thrift_rack/version.rb
CHANGED
data/lib/thrift_rack.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thrift_rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xuxiangyang
|
@@ -14,98 +14,98 @@ dependencies:
|
|
14
14
|
name: rack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: thrift
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.10.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.10.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: excon
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.62.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.62.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: connection_pool
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 2.2.1
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 2.2.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '1.16'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.16'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '10.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '10.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: pry
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: thrift http rakc server
|
@@ -115,7 +115,7 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- .gitignore
|
118
|
+
- ".gitignore"
|
119
119
|
- CODE_OF_CONDUCT.md
|
120
120
|
- Gemfile
|
121
121
|
- Gemfile.lock
|
@@ -126,12 +126,12 @@ files:
|
|
126
126
|
- lib/config.ru
|
127
127
|
- lib/thrift_rack.rb
|
128
128
|
- lib/thrift_rack/client.rb
|
129
|
+
- lib/thrift_rack/excon_pool.rb
|
129
130
|
- lib/thrift_rack/format_check.rb
|
130
131
|
- lib/thrift_rack/http_client_transport.rb
|
131
132
|
- lib/thrift_rack/logger.rb
|
132
133
|
- lib/thrift_rack/ping.rb
|
133
134
|
- lib/thrift_rack/server.rb
|
134
|
-
- lib/thrift_rack/transport_pool.rb
|
135
135
|
- lib/thrift_rack/version.rb
|
136
136
|
- thrift_rack.gemspec
|
137
137
|
homepage: https://github.com/xuxiangyang/thrift_rack
|
@@ -144,17 +144,17 @@ require_paths:
|
|
144
144
|
- lib
|
145
145
|
required_ruby_version: !ruby/object:Gem::Requirement
|
146
146
|
requirements:
|
147
|
-
- -
|
147
|
+
- - ">="
|
148
148
|
- !ruby/object:Gem::Version
|
149
149
|
version: '0'
|
150
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
151
|
requirements:
|
152
|
-
- -
|
152
|
+
- - ">="
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.
|
157
|
+
rubygems_version: 2.6.14
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: thrift http rakc server
|