thrift_rack 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/thrift_rack/client.rb +4 -6
- data/lib/thrift_rack/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb6efda090df3d41b7af5cc730c0e97c08b71147
|
4
|
+
data.tar.gz: 285c58f9efa4842f91b13b1f6ddd0355b4d3fae6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51fb0793b17b90e99e6632fa262f2fa8be0e15a6f3fc27ced29feca90661a8dc1dd5345986fb82d1310e5d38877f001ff5f2f4cffb8d7d633f542837043305f9
|
7
|
+
data.tar.gz: b1031c96f4d269471b1e24090005160461cd1b23aa6a09e71ec0ed21126532335dcda92636ac53befe843a5ac98904f106911504ca3b74273abb0bd4268b6601
|
data/Gemfile.lock
CHANGED
data/lib/thrift_rack/client.rb
CHANGED
@@ -3,14 +3,11 @@ require 'securerandom'
|
|
3
3
|
class ThriftRack
|
4
4
|
class Client
|
5
5
|
def initialize(url, client_klass, request_id)
|
6
|
-
@
|
7
|
-
@request_id = request_id
|
6
|
+
@request_id = request_id || "no-request"
|
8
7
|
@url = url
|
9
8
|
@transport = Thrift::HTTPClientTransport.new(url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE)
|
10
|
-
@transport.add_headers({"X-Request-ID" => @request_id || "no-request", "X-Rpc-ID" => @rpc_id})
|
11
9
|
protocol = protocol_factory.get_protocol(@transport)
|
12
10
|
@client = client_klass.new(protocol)
|
13
|
-
|
14
11
|
end
|
15
12
|
|
16
13
|
def logger
|
@@ -26,15 +23,16 @@ class ThriftRack
|
|
26
23
|
self.class_eval do
|
27
24
|
define_method method.to_sym do |*args|
|
28
25
|
begin
|
26
|
+
rpc_id = SecureRandom.uuid
|
29
27
|
request_at = Time.now
|
30
|
-
@transport.add_headers({"X-Rpc-Func" => method.to_s})
|
28
|
+
@transport.add_headers({"X-Request-ID" => @request_id, "X-Rpc-ID" => rpc_id, "X-Rpc-Func" => method.to_s})
|
31
29
|
@client.send(method, *args)
|
32
30
|
ensure
|
33
31
|
end_time = Time.now
|
34
32
|
self.logger.info(JSON.dump({
|
35
33
|
request_at: request_at.iso8601,
|
36
34
|
request_id: @request_id,
|
37
|
-
rpc_id:
|
35
|
+
rpc_id: rpc_id,
|
38
36
|
duration: ((end_time - request_at) * 1000).round(4),
|
39
37
|
path: URI(@url).path,
|
40
38
|
func: method,
|
data/lib/thrift_rack/version.rb
CHANGED