thrift-client 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- metadata +11 -13
- data/lib/thrift_client/multiplexed_client.rb +0 -26
- data/lib/thrift_client/multiplexed_processor.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 323c83c512e4cfa2ca458c4a3973a27b29c22d84
|
4
|
+
data.tar.gz: db6a21690999bb845906059d620442805d7a110f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15d87790593e1ea05c926bbcd4d15e977640402796cf1e9604ae1e5634b46fe0acae9cf486e8a7e84ce58c69993ac2af55c3ec48e9af3c89c840ba6955c2ab97
|
7
|
+
data.tar.gz: 51875d0b9398e1c1794ad3f90aeb6f79399ae9d3f796c39f025b6d758937015689205234086549ba63e7dc26fa208ff30891faa0696a07f5654b33e3c65f4926
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thrift-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ted Wang
|
@@ -30,22 +30,20 @@ executables: []
|
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
|
-
- lib/thrift_client/abstract_thrift_client.rb
|
34
33
|
- lib/thrift_client/abstract_server.rb
|
34
|
+
- lib/thrift_client/abstract_thrift_client.rb
|
35
35
|
- lib/thrift_client/multi_client_server.rb
|
36
|
-
- lib/thrift_client/multiplexed_client.rb
|
37
|
-
- lib/thrift_client/thrift.rb
|
38
|
-
- lib/thrift_client/multiplexed_processor.rb
|
39
36
|
- lib/thrift_client/single_client_server.rb
|
37
|
+
- lib/thrift_client/thrift.rb
|
40
38
|
- lib/thrift_client.rb
|
39
|
+
- test/client_test.rb
|
40
|
+
- test/foobar_constants.rb
|
41
41
|
- test/foobar_service.rb
|
42
|
-
- test/server.rb
|
43
42
|
- test/foobar_types.rb
|
44
|
-
- test/foobar_constants.rb
|
45
|
-
- test/client_test.rb
|
46
43
|
- test/multiplexed_protocol_test.rb
|
47
|
-
- test/options_config_test.rb
|
48
44
|
- test/multiplexed_server.rb
|
45
|
+
- test/options_config_test.rb
|
46
|
+
- test/server.rb
|
49
47
|
homepage: http://www.ximalaya.com
|
50
48
|
licenses:
|
51
49
|
- MIT2.0
|
@@ -71,11 +69,11 @@ signing_key:
|
|
71
69
|
specification_version: 4
|
72
70
|
summary: A Thrift client wrapper that encapsulates some common behavior.
|
73
71
|
test_files:
|
72
|
+
- test/client_test.rb
|
73
|
+
- test/foobar_constants.rb
|
74
74
|
- test/foobar_service.rb
|
75
|
-
- test/server.rb
|
76
75
|
- test/foobar_types.rb
|
77
|
-
- test/foobar_constants.rb
|
78
|
-
- test/client_test.rb
|
79
76
|
- test/multiplexed_protocol_test.rb
|
80
|
-
- test/options_config_test.rb
|
81
77
|
- test/multiplexed_server.rb
|
78
|
+
- test/options_config_test.rb
|
79
|
+
- test/server.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Thrift
|
2
|
-
module Client
|
3
|
-
alias :old_initialize :initialize
|
4
|
-
|
5
|
-
def initialize(service, iprot, oprot=nil)
|
6
|
-
old_initialize(iprot, oprot)
|
7
|
-
@service = service
|
8
|
-
end
|
9
|
-
|
10
|
-
def send_message(name, args_class, args = {})
|
11
|
-
@oprot.write_message_begin(@service + ':' + name, MessageTypes::CALL, @seqid)
|
12
|
-
data = args_class.new
|
13
|
-
args.each do |k, v|
|
14
|
-
data.send("#{k.to_s}=", v)
|
15
|
-
end
|
16
|
-
begin
|
17
|
-
data.write(@oprot)
|
18
|
-
rescue StandardError => e
|
19
|
-
@oprot.trans.close
|
20
|
-
raise e
|
21
|
-
end
|
22
|
-
@oprot.write_message_end
|
23
|
-
@oprot.trans.flush
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Thrift
|
2
|
-
class MultiplexedProcessor
|
3
|
-
def initialize
|
4
|
-
@map = Hash.new
|
5
|
-
end
|
6
|
-
|
7
|
-
def register(service, processor)
|
8
|
-
processor.instance_variable_set(:@service, service)
|
9
|
-
@map[service] = processor
|
10
|
-
end
|
11
|
-
|
12
|
-
def process(iprot, oprot)
|
13
|
-
name, type, seqid = iprot.read_message_begin
|
14
|
-
|
15
|
-
service, method = name.split(':')
|
16
|
-
processor = @map[service]
|
17
|
-
if processor.respond_to?("process_#{method}")
|
18
|
-
processor.send("process_#{method}", seqid, iprot, oprot)
|
19
|
-
true
|
20
|
-
else
|
21
|
-
iprot.skip(Types::STRUCT)
|
22
|
-
iprot.read_message_end
|
23
|
-
x = ApplicationException.new(ApplicationException::UNKNOWN_METHOD, 'Unknown function ' + name)
|
24
|
-
oprot.write_message_begin(name, MessageTypes::EXCEPTION, seqid)
|
25
|
-
x.write(oprot)
|
26
|
-
oprot.write_message_end
|
27
|
-
oprot.trans.flush
|
28
|
-
false
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
module Processor
|
34
|
-
def write_result(result, oprot, name, seqid)
|
35
|
-
oprot.write_message_begin(@service + ':' + name, MessageTypes::REPLY, seqid)
|
36
|
-
result.write(oprot)
|
37
|
-
oprot.write_message_end
|
38
|
-
oprot.trans.flush
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|