thrift_rack 0.1.3 → 0.1.4

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: d19c048c57cf99b79431ab935d3d183a1c80180c
4
- data.tar.gz: 6729dc19dee7c3750f07afe559354545d338e473
3
+ metadata.gz: fb6efda090df3d41b7af5cc730c0e97c08b71147
4
+ data.tar.gz: 285c58f9efa4842f91b13b1f6ddd0355b4d3fae6
5
5
  SHA512:
6
- metadata.gz: 42500aee8a0977dc5595c765d8810d01b02738079baf9299483ecb14a238dd24c20d970162e65673ea9db11a8e2f5f13fca11f3e4bf65030fa35592c3058335d
7
- data.tar.gz: b4ee7610d0a0a2c881514627c84d8fa79d73038b8f506e4a23d0281faa102dcc21cc4e251bdfd4de51bbaff65d99ccfba6f0eabb1655d147201eae1836a9c936
6
+ metadata.gz: 51fb0793b17b90e99e6632fa262f2fa8be0e15a6f3fc27ced29feca90661a8dc1dd5345986fb82d1310e5d38877f001ff5f2f4cffb8d7d633f542837043305f9
7
+ data.tar.gz: b1031c96f4d269471b1e24090005160461cd1b23aa6a09e71ec0ed21126532335dcda92636ac53befe843a5ac98904f106911504ca3b74273abb0bd4268b6601
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thrift_rack (0.1.1)
4
+ thrift_rack (0.1.3)
5
5
  rack (>= 2.0)
6
6
  thrift (~> 0.10.0)
7
7
 
@@ -3,14 +3,11 @@ require 'securerandom'
3
3
  class ThriftRack
4
4
  class Client
5
5
  def initialize(url, client_klass, request_id)
6
- @rpc_id = SecureRandom.uuid
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: @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,
@@ -1,3 +1,3 @@
1
1
  class ThriftRack
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - xuxiangyang