upfluence-thrift 1.0.12 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +5 -5
  2. data/benchmark/gen-rb/benchmark_constants.rb +1 -1
  3. data/benchmark/gen-rb/benchmark_service.rb +21 -10
  4. data/benchmark/gen-rb/benchmark_types.rb +1 -1
  5. data/lib/thrift/server/rack_application.rb +30 -19
  6. data/spec/gen-rb/base/base_service.rb +21 -10
  7. data/spec/gen-rb/base/base_service_constants.rb +1 -1
  8. data/spec/gen-rb/base/base_service_types.rb +1 -1
  9. data/spec/gen-rb/extended/extended_service.rb +21 -10
  10. data/spec/gen-rb/extended/extended_service_constants.rb +1 -1
  11. data/spec/gen-rb/extended/extended_service_types.rb +1 -1
  12. data/spec/gen-rb/flat/namespaced_nonblocking_service.rb +67 -40
  13. data/spec/gen-rb/flat/referenced_constants.rb +1 -1
  14. data/spec/gen-rb/flat/referenced_types.rb +1 -1
  15. data/spec/gen-rb/flat/thrift_namespaced_spec_constants.rb +1 -1
  16. data/spec/gen-rb/flat/thrift_namespaced_spec_types.rb +1 -1
  17. data/spec/gen-rb/namespaced_spec_namespace/namespaced_nonblocking_service.rb +67 -40
  18. data/spec/gen-rb/namespaced_spec_namespace/thrift_namespaced_spec_constants.rb +1 -1
  19. data/spec/gen-rb/namespaced_spec_namespace/thrift_namespaced_spec_types.rb +1 -1
  20. data/spec/gen-rb/nonblocking_service.rb +67 -40
  21. data/spec/gen-rb/other_namespace/referenced_constants.rb +1 -1
  22. data/spec/gen-rb/other_namespace/referenced_types.rb +1 -1
  23. data/spec/gen-rb/thrift_spec_constants.rb +1 -1
  24. data/spec/gen-rb/thrift_spec_types.rb +1 -1
  25. data/spec/rack_application_spec.rb +1 -1
  26. data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +44 -44
  27. data/test/debug_proto/gen-rb/debug_proto_test_types.rb +1 -1
  28. data/test/debug_proto/gen-rb/empty_service.rb +8 -1
  29. data/test/debug_proto/gen-rb/inherited.rb +21 -10
  30. data/test/debug_proto/gen-rb/reverse_order_service.rb +21 -10
  31. data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +24 -13
  32. data/test/debug_proto/gen-rb/srv.rb +83 -52
  33. metadata +11 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c353ea4ae1a794c173cf39fcdd3186942dace6c1
4
- data.tar.gz: 1fdb70681939b79e750691d6d630e71accfa19cc
2
+ SHA256:
3
+ metadata.gz: 86be9e073b58c320330f5ac9f55b33d9886939785ae72282dc54d1682060352a
4
+ data.tar.gz: 3f057f5442bc6e9faf3a35e276210ffd4789bf561f1e70a934cfbb747b8dfa29
5
5
  SHA512:
6
- metadata.gz: 56c22d1ac24805f545a7851aa93b3003cdcc70eb3f00e423ca8301a64d11fb2399eb895f47711ccb4df2eee581faeaff34dcf897c03dcea2e881d7c032e60aee
7
- data.tar.gz: e6839dcb0d4a211b5d9e99ea718d1094201f68aeeb60f14cf8658a151b9c1e42477c62e9335403334ff6aebd8866c9b48889bd564d9eb5f82c4fabb7fe848c68
6
+ metadata.gz: 477fa6678b03f067306dc38d4041a505963666a4575c25a81b3fa4796239e21cb7c473fbc16413b9e90b0c17ba8a539685429274f851167bb6af88d1f1313891
7
+ data.tar.gz: 5ae56c20604b78f69176f4b4e9b7ad8e7af0484f51b3ec1895220801c4bed08dcae3dc788b596479910d25e0ee3df884008d547d855da099e046b2184a0badae
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler (1.0.0-upfluence)
2
+ # Autogenerated by Thrift Compiler (2.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler (1.0.0-upfluence)
2
+ # Autogenerated by Thrift Compiler (2.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -9,19 +9,28 @@ require 'benchmark_types'
9
9
 
10
10
  module ThriftBenchmark
11
11
  module BenchmarkService
12
+ SERVICE_NAME = "BenchmarkService"
13
+ PROGRAM_NAME = ""
14
+
12
15
  class Client
13
16
  include ::Thrift::Client
14
17
 
15
- def fibonacci(n)
16
- send_fibonacci(n)
17
- return recv_fibonacci()
18
+ def self.from_provider(provider)
19
+ Client.new(*provider.build(", BenchmarkService"))
20
+ end
21
+
22
+ def fibonacci(ctx, n)
23
+ @middleware.handle_binary(ctx, 'fibonacci', Fibonacci_args.new(:n => n)) do |ctx, args|
24
+ send_fibonacci(ctx, args.n)
25
+ return recv_fibonacci(ctx)
26
+ end
18
27
  end
19
28
 
20
- def send_fibonacci(n)
29
+ def send_fibonacci(ctx, n)
21
30
  send_message('fibonacci', Fibonacci_args, :n => n)
22
31
  end
23
32
 
24
- def recv_fibonacci()
33
+ def recv_fibonacci(ctx)
25
34
  result = receive_message(Fibonacci_result)
26
35
  return result.success unless result.success.nil?
27
36
  raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'fibonacci failed: unknown result')
@@ -32,11 +41,13 @@ module ThriftBenchmark
32
41
  class Processor
33
42
  include ::Thrift::Processor
34
43
 
35
- def process_fibonacci(seqid, iprot, oprot)
44
+ def process_fibonacci(ctx, seqid, iprot, oprot)
36
45
  args = read_args(iprot, Fibonacci_args)
37
- result = Fibonacci_result.new()
38
- result.success = @handler.fibonacci(args.n)
39
- write_result(result, oprot, 'fibonacci', seqid)
46
+ @middleware.handle_binary(ctx, 'fibonacci', args) do |ctx, args|
47
+ result = Fibonacci_result.new()
48
+ result.success = @handler.fibonacci(ctx, args.n)
49
+ write_result(result, oprot, 'fibonacci', seqid)
50
+ end
40
51
  end
41
52
 
42
53
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler (1.0.0-upfluence)
2
+ # Autogenerated by Thrift Compiler (2.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -21,37 +21,48 @@ require 'rack'
21
21
 
22
22
  module Thrift
23
23
  class RackApplication
24
- THRIFT_HEADER = "application/x-thrift"
24
+ THRIFT_HEADER = 'application/x-thrift'.freeze
25
25
 
26
26
  def self.for(path, processor, protocol_factory)
27
27
  Rack::Builder.new do
28
28
  map path do
29
- run lambda { |env|
30
- request = Rack::Request.new(env)
31
- if RackApplication.valid_thrift_request?(request)
32
- RackApplication.successful_request(request, processor, protocol_factory)
33
- else
34
- RackApplication.failed_request
35
- end
36
- }
29
+ run Thrift::RackApplication.new(processor, protocol_factory)
37
30
  end
38
31
  end
39
32
  end
40
33
 
41
- def self.successful_request(rack_request, processor, protocol_factory)
42
- response = Rack::Response.new([], 200, {'Content-Type' => THRIFT_HEADER})
43
- transport = IOStreamTransport.new rack_request.body, response
44
- protocol = protocol_factory.get_protocol transport
45
- processor.process protocol, protocol
46
- response
34
+ def initialize(processor, protocol_factory)
35
+ @processor = processor
36
+ @protocol_factory = protocol_factory
37
+ @headers = { 'Content-Type' => THRIFT_HEADER }
47
38
  end
48
39
 
49
- def self.failed_request
50
- Rack::Response.new(['Not Found'], 404, {'Content-Type' => THRIFT_HEADER})
40
+ def call(env)
41
+ req = Rack::Request.new(env)
42
+
43
+ if valid_thrift_request?(req)
44
+ successful_request(req)
45
+ else
46
+ failed_request
47
+ end
48
+ end
49
+
50
+ def successful_request(req)
51
+ resp = Rack::Response.new([], 200, @headers)
52
+ transport = IOStreamTransport.new req.body, resp
53
+ protocol = @protocol_factory.get_protocol transport
54
+
55
+ @processor.process protocol, protocol
56
+
57
+ [resp.status, resp.headers, resp.body]
58
+ end
59
+
60
+ def failed_request
61
+ [404, @headers, 'Not found']
51
62
  end
52
63
 
53
- def self.valid_thrift_request?(rack_request)
54
- rack_request.post? && rack_request.env["CONTENT_TYPE"] == THRIFT_HEADER
64
+ def valid_thrift_request?(req)
65
+ req.post? && req.env['CONTENT_TYPE'] == THRIFT_HEADER
55
66
  end
56
67
  end
57
68
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler (1.0.0-upfluence)
2
+ # Autogenerated by Thrift Compiler (2.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -9,19 +9,28 @@ require 'base/base_service_types'
9
9
 
10
10
  module Base
11
11
  module BaseService
12
+ SERVICE_NAME = "BaseService"
13
+ PROGRAM_NAME = ""
14
+
12
15
  class Client
13
16
  include ::Thrift::Client
14
17
 
15
- def greeting(english)
16
- send_greeting(english)
17
- return recv_greeting()
18
+ def self.from_provider(provider)
19
+ Client.new(*provider.build(", BaseService"))
20
+ end
21
+
22
+ def greeting(ctx, english)
23
+ @middleware.handle_binary(ctx, 'greeting', Greeting_args.new(:english => english)) do |ctx, args|
24
+ send_greeting(ctx, args.english)
25
+ return recv_greeting(ctx)
26
+ end
18
27
  end
19
28
 
20
- def send_greeting(english)
29
+ def send_greeting(ctx, english)
21
30
  send_message('greeting', Greeting_args, :english => english)
22
31
  end
23
32
 
24
- def recv_greeting()
33
+ def recv_greeting(ctx)
25
34
  result = receive_message(Greeting_result)
26
35
  return result.success unless result.success.nil?
27
36
  raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'greeting failed: unknown result')
@@ -32,11 +41,13 @@ module Base
32
41
  class Processor
33
42
  include ::Thrift::Processor
34
43
 
35
- def process_greeting(seqid, iprot, oprot)
44
+ def process_greeting(ctx, seqid, iprot, oprot)
36
45
  args = read_args(iprot, Greeting_args)
37
- result = Greeting_result.new()
38
- result.success = @handler.greeting(args.english)
39
- write_result(result, oprot, 'greeting', seqid)
46
+ @middleware.handle_binary(ctx, 'greeting', args) do |ctx, args|
47
+ result = Greeting_result.new()
48
+ result.success = @handler.greeting(ctx, args.english)
49
+ write_result(result, oprot, 'greeting', seqid)
50
+ end
40
51
  end
41
52
 
42
53
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler (1.0.0-upfluence)
2
+ # Autogenerated by Thrift Compiler (2.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler (1.0.0-upfluence)
2
+ # Autogenerated by Thrift Compiler (2.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler (1.0.0-upfluence)
2
+ # Autogenerated by Thrift Compiler (2.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -10,19 +10,28 @@ require 'extended/extended_service_types'
10
10
 
11
11
  module Extended
12
12
  module ExtendedService
13
+ SERVICE_NAME = "ExtendedService"
14
+ PROGRAM_NAME = ""
15
+
13
16
  class Client < ::Base::BaseService::Client
14
17
  include ::Thrift::Client
15
18
 
16
- def ping()
17
- send_ping()
18
- recv_ping()
19
+ def self.from_provider(provider)
20
+ Client.new(*provider.build(", ExtendedService"))
21
+ end
22
+
23
+ def ping(ctx)
24
+ @middleware.handle_binary(ctx, 'ping', Ping_args.new()) do |ctx, args|
25
+ send_ping(ctx, )
26
+ recv_ping(ctx)
27
+ end
19
28
  end
20
29
 
21
- def send_ping()
30
+ def send_ping(ctx)
22
31
  send_message('ping', Ping_args)
23
32
  end
24
33
 
25
- def recv_ping()
34
+ def recv_ping(ctx)
26
35
  result = receive_message(Ping_result)
27
36
  return
28
37
  end
@@ -32,11 +41,13 @@ module Extended
32
41
  class Processor < ::Base::BaseService::Processor
33
42
  include ::Thrift::Processor
34
43
 
35
- def process_ping(seqid, iprot, oprot)
44
+ def process_ping(ctx, seqid, iprot, oprot)
36
45
  args = read_args(iprot, Ping_args)
37
- result = Ping_result.new()
38
- @handler.ping()
39
- write_result(result, oprot, 'ping', seqid)
46
+ @middleware.handle_binary(ctx, 'ping', args) do |ctx, args|
47
+ result = Ping_result.new()
48
+ @handler.ping(ctx, )
49
+ write_result(result, oprot, 'ping', seqid)
50
+ end
40
51
  end
41
52
 
42
53
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler (1.0.0-upfluence)
2
+ # Autogenerated by Thrift Compiler (2.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler (1.0.0-upfluence)
2
+ # Autogenerated by Thrift Compiler (2.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler (1.0.0-upfluence)
2
+ # Autogenerated by Thrift Compiler (2.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -9,63 +9,80 @@ require 'thrift_namespaced_spec_types'
9
9
 
10
10
  module NamespacedSpecNamespace
11
11
  module NamespacedNonblockingService
12
+ SERVICE_NAME = "NamespacedNonblockingService"
13
+ PROGRAM_NAME = ""
14
+
12
15
  class Client
13
16
  include ::Thrift::Client
14
17
 
15
- def greeting(english)
16
- send_greeting(english)
17
- return recv_greeting()
18
+ def self.from_provider(provider)
19
+ Client.new(*provider.build(", NamespacedNonblockingService"))
20
+ end
21
+
22
+ def greeting(ctx, english)
23
+ @middleware.handle_binary(ctx, 'greeting', Greeting_args.new(:english => english)) do |ctx, args|
24
+ send_greeting(ctx, args.english)
25
+ return recv_greeting(ctx)
26
+ end
18
27
  end
19
28
 
20
- def send_greeting(english)
29
+ def send_greeting(ctx, english)
21
30
  send_message('greeting', Greeting_args, :english => english)
22
31
  end
23
32
 
24
- def recv_greeting()
33
+ def recv_greeting(ctx)
25
34
  result = receive_message(Greeting_result)
26
35
  return result.success unless result.success.nil?
27
36
  raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'greeting failed: unknown result')
28
37
  end
29
38
 
30
- def block()
31
- send_block()
32
- return recv_block()
39
+ def block(ctx)
40
+ @middleware.handle_binary(ctx, 'block', Block_args.new()) do |ctx, args|
41
+ send_block(ctx, )
42
+ return recv_block(ctx)
43
+ end
33
44
  end
34
45
 
35
- def send_block()
46
+ def send_block(ctx)
36
47
  send_message('block', Block_args)
37
48
  end
38
49
 
39
- def recv_block()
50
+ def recv_block(ctx)
40
51
  result = receive_message(Block_result)
41
52
  return result.success unless result.success.nil?
42
53
  raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'block failed: unknown result')
43
54
  end
44
55
 
45
- def unblock(n)
46
- send_unblock(n)
56
+ def unblock(ctx, n)
57
+ @middleware.handle_unary(ctx, 'unblock', Unblock_args.new(:n => n)) do |ctx, args|
58
+ send_unblock(ctx, args.n)
59
+ end
47
60
  end
48
61
 
49
- def send_unblock(n)
62
+ def send_unblock(ctx, n)
50
63
  send_oneway_message('unblock', Unblock_args, :n => n)
51
64
  end
52
- def shutdown()
53
- send_shutdown()
65
+ def shutdown(ctx)
66
+ @middleware.handle_unary(ctx, 'shutdown', Shutdown_args.new()) do |ctx, args|
67
+ send_shutdown(ctx, )
68
+ end
54
69
  end
55
70
 
56
- def send_shutdown()
71
+ def send_shutdown(ctx)
57
72
  send_oneway_message('shutdown', Shutdown_args)
58
73
  end
59
- def sleep(seconds)
60
- send_sleep(seconds)
61
- recv_sleep()
74
+ def sleep(ctx, seconds)
75
+ @middleware.handle_binary(ctx, 'sleep', Sleep_args.new(:seconds => seconds)) do |ctx, args|
76
+ send_sleep(ctx, args.seconds)
77
+ recv_sleep(ctx)
78
+ end
62
79
  end
63
80
 
64
- def send_sleep(seconds)
81
+ def send_sleep(ctx, seconds)
65
82
  send_message('sleep', Sleep_args, :seconds => seconds)
66
83
  end
67
84
 
68
- def recv_sleep()
85
+ def recv_sleep(ctx)
69
86
  result = receive_message(Sleep_result)
70
87
  return
71
88
  end
@@ -75,37 +92,47 @@ module NamespacedSpecNamespace
75
92
  class Processor
76
93
  include ::Thrift::Processor
77
94
 
78
- def process_greeting(seqid, iprot, oprot)
95
+ def process_greeting(ctx, seqid, iprot, oprot)
79
96
  args = read_args(iprot, Greeting_args)
80
- result = Greeting_result.new()
81
- result.success = @handler.greeting(args.english)
82
- write_result(result, oprot, 'greeting', seqid)
97
+ @middleware.handle_binary(ctx, 'greeting', args) do |ctx, args|
98
+ result = Greeting_result.new()
99
+ result.success = @handler.greeting(ctx, args.english)
100
+ write_result(result, oprot, 'greeting', seqid)
101
+ end
83
102
  end
84
103
 
85
- def process_block(seqid, iprot, oprot)
104
+ def process_block(ctx, seqid, iprot, oprot)
86
105
  args = read_args(iprot, Block_args)
87
- result = Block_result.new()
88
- result.success = @handler.block()
89
- write_result(result, oprot, 'block', seqid)
106
+ @middleware.handle_binary(ctx, 'block', args) do |ctx, args|
107
+ result = Block_result.new()
108
+ result.success = @handler.block(ctx, )
109
+ write_result(result, oprot, 'block', seqid)
110
+ end
90
111
  end
91
112
 
92
- def process_unblock(seqid, iprot, oprot)
113
+ def process_unblock(ctx, seqid, iprot, oprot)
93
114
  args = read_args(iprot, Unblock_args)
94
- @handler.unblock(args.n)
95
- return
115
+ @middleware.handle_unary(ctx, 'unblock', args) do |ctx, args|
116
+ @handler.unblock(ctx, args.n)
117
+ return
118
+ end
96
119
  end
97
120
 
98
- def process_shutdown(seqid, iprot, oprot)
121
+ def process_shutdown(ctx, seqid, iprot, oprot)
99
122
  args = read_args(iprot, Shutdown_args)
100
- @handler.shutdown()
101
- return
123
+ @middleware.handle_unary(ctx, 'shutdown', args) do |ctx, args|
124
+ @handler.shutdown(ctx, )
125
+ return
126
+ end
102
127
  end
103
128
 
104
- def process_sleep(seqid, iprot, oprot)
129
+ def process_sleep(ctx, seqid, iprot, oprot)
105
130
  args = read_args(iprot, Sleep_args)
106
- result = Sleep_result.new()
107
- @handler.sleep(args.seconds)
108
- write_result(result, oprot, 'sleep', seqid)
131
+ @middleware.handle_binary(ctx, 'sleep', args) do |ctx, args|
132
+ result = Sleep_result.new()
133
+ @handler.sleep(ctx, args.seconds)
134
+ write_result(result, oprot, 'sleep', seqid)
135
+ end
109
136
  end
110
137
 
111
138
  end