thrift 0.0.751142 → 0.0.810255.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/CHANGELOG +3 -1
  2. data/Manifest +47 -44
  3. data/README +19 -6
  4. data/Rakefile +1 -1
  5. data/benchmark/Benchmark.thrift +19 -0
  6. data/benchmark/benchmark.rb +20 -3
  7. data/benchmark/client.rb +20 -2
  8. data/benchmark/server.rb +22 -4
  9. data/benchmark/thin_server.rb +22 -4
  10. data/ext/binary_protocol_accelerated.c +32 -21
  11. data/ext/binary_protocol_accelerated.h +19 -0
  12. data/ext/compact_protocol.c +665 -0
  13. data/ext/compact_protocol.h +20 -0
  14. data/ext/constants.h +19 -1
  15. data/ext/extconf.rb +19 -0
  16. data/ext/macros.h +41 -0
  17. data/ext/memory_buffer.c +29 -5
  18. data/ext/memory_buffer.h +19 -0
  19. data/ext/protocol.c +20 -1
  20. data/ext/protocol.h +19 -0
  21. data/ext/struct.c +115 -83
  22. data/ext/struct.h +19 -0
  23. data/ext/thrift_native.c +23 -2
  24. data/lib/thrift/client.rb +19 -1
  25. data/lib/thrift/core_ext/fixnum.rb +29 -0
  26. data/lib/thrift/core_ext.rb +23 -0
  27. data/lib/thrift/exceptions.rb +19 -2
  28. data/lib/thrift/processor.rb +19 -1
  29. data/lib/thrift/protocol/base_protocol.rb +290 -0
  30. data/lib/thrift/protocol/{binaryprotocol.rb → binary_protocol.rb} +27 -15
  31. data/lib/thrift/protocol/binary_protocol_accelerated.rb +35 -0
  32. data/lib/thrift/protocol/compact_protocol.rb +422 -0
  33. data/lib/thrift/serializer/deserializer.rb +33 -0
  34. data/lib/thrift/serializer/serializer.rb +34 -0
  35. data/lib/thrift/server/base_server.rb +31 -0
  36. data/lib/thrift/server/{httpserver.rb → mongrel_http_server.rb} +19 -5
  37. data/lib/thrift/server/{nonblockingserver.rb → nonblocking_server.rb} +42 -24
  38. data/lib/thrift/server/simple_server.rb +43 -0
  39. data/lib/thrift/server/thread_pool_server.rb +75 -0
  40. data/lib/thrift/server/threaded_server.rb +47 -0
  41. data/lib/thrift/struct.rb +73 -47
  42. data/lib/thrift/thrift_native.rb +24 -0
  43. data/lib/thrift/transport/base_server_transport.rb +37 -0
  44. data/lib/thrift/transport/base_transport.rb +70 -0
  45. data/lib/thrift/transport/buffered_transport.rb +77 -0
  46. data/lib/thrift/transport/framed_transport.rb +90 -0
  47. data/lib/thrift/transport/http_client_transport.rb +45 -0
  48. data/lib/thrift/transport/io_stream_transport.rb +39 -0
  49. data/lib/thrift/transport/memory_buffer_transport.rb +96 -0
  50. data/lib/thrift/transport/server_socket.rb +63 -0
  51. data/lib/thrift/transport/socket.rb +22 -53
  52. data/lib/thrift/transport/unix_server_socket.rb +60 -0
  53. data/lib/thrift/transport/unix_socket.rb +40 -0
  54. data/lib/thrift/types.rb +20 -2
  55. data/lib/thrift.rb +50 -19
  56. data/script/proto_benchmark.rb +121 -0
  57. data/script/read_struct.rb +43 -0
  58. data/script/write_struct.rb +30 -0
  59. data/spec/ThriftSpec.thrift +40 -2
  60. data/spec/{protocol_spec.rb → base_protocol_spec.rb} +25 -7
  61. data/spec/{transport_spec.rb → base_transport_spec.rb} +44 -52
  62. data/spec/binary_protocol_accelerated_spec.rb +41 -0
  63. data/spec/{binaryprotocol_spec.rb → binary_protocol_spec.rb} +20 -2
  64. data/spec/{binaryprotocol_spec_shared.rb → binary_protocol_spec_shared.rb} +117 -16
  65. data/spec/client_spec.rb +23 -4
  66. data/spec/compact_protocol_spec.rb +117 -0
  67. data/spec/exception_spec.rb +19 -0
  68. data/spec/http_client_spec.rb +49 -0
  69. data/spec/{httpserver_spec.rb → mongrel_http_server_spec.rb} +26 -7
  70. data/spec/{nonblockingserver_spec.rb → nonblocking_server_spec.rb} +25 -5
  71. data/spec/processor_spec.rb +19 -0
  72. data/spec/serializer_spec.rb +27 -10
  73. data/spec/server_socket_spec.rb +80 -0
  74. data/spec/server_spec.rb +35 -16
  75. data/spec/socket_spec.rb +19 -55
  76. data/spec/socket_spec_shared.rb +19 -0
  77. data/spec/spec_helper.rb +34 -9
  78. data/spec/struct_spec.rb +26 -18
  79. data/spec/types_spec.rb +19 -1
  80. data/spec/{unixsocket_spec.rb → unix_socket_spec.rb} +19 -1
  81. data/thrift.gemspec +6 -6
  82. data.tar.gz.sig +0 -0
  83. metadata +80 -70
  84. metadata.gz.sig +0 -0
  85. data/COPYING +0 -14
  86. data/LICENSE +0 -14
  87. data/Makefile.am +0 -15
  88. data/benchmark/gen-rb/BenchmarkService.rb +0 -81
  89. data/benchmark/gen-rb/Benchmark_constants.rb +0 -11
  90. data/benchmark/gen-rb/Benchmark_types.rb +0 -10
  91. data/lib/thrift/deprecation.rb +0 -155
  92. data/lib/thrift/protocol/binaryprotocolaccelerated.rb +0 -19
  93. data/lib/thrift/protocol/tbinaryprotocol.rb +0 -2
  94. data/lib/thrift/protocol/tprotocol.rb +0 -2
  95. data/lib/thrift/protocol.rb +0 -270
  96. data/lib/thrift/serializer.rb +0 -27
  97. data/lib/thrift/server/thttpserver.rb +0 -2
  98. data/lib/thrift/server/tserver.rb +0 -2
  99. data/lib/thrift/server.rb +0 -135
  100. data/lib/thrift/thrift.rb +0 -14
  101. data/lib/thrift/transport/httpclient.rb +0 -29
  102. data/lib/thrift/transport/thttpclient.rb +0 -2
  103. data/lib/thrift/transport/tsocket.rb +0 -2
  104. data/lib/thrift/transport/ttransport.rb +0 -2
  105. data/lib/thrift/transport/unixsocket.rb +0 -58
  106. data/lib/thrift/transport.rb +0 -319
  107. data/spec/backwards_compatibility_spec.rb +0 -136
  108. data/spec/binaryprotocolaccelerated_spec.rb +0 -101
  109. data/spec/deprecation_spec.rb +0 -443
  110. data/spec/gen-rb/NonblockingService.rb +0 -268
  111. data/spec/gen-rb/ThriftSpec_constants.rb +0 -11
  112. data/spec/gen-rb/ThriftSpec_types.rb +0 -134
  113. data/spec/httpclient_spec.rb +0 -31
@@ -1,134 +0,0 @@
1
- #
2
- # Autogenerated by Thrift
3
- #
4
- # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
- #
6
-
7
- require 'thrift/protocol'
8
-
9
- module SpecNamespace
10
- class Hello
11
- include ::Thrift::Struct
12
- GREETING = 1
13
-
14
- Thrift::Struct.field_accessor self, :greeting
15
- FIELDS = {
16
- GREETING => {:type => Thrift::Types::STRING, :name => 'greeting', :default => %q"hello world"}
17
- }
18
-
19
- def struct_fields; FIELDS; end
20
-
21
- def validate
22
- end
23
-
24
- end
25
-
26
- class Foo
27
- include ::Thrift::Struct
28
- SIMPLE = 1
29
- WORDS = 2
30
- HELLO = 3
31
- INTS = 4
32
- COMPLEX = 5
33
- SHORTS = 6
34
- OPT_STRING = 7
35
-
36
- Thrift::Struct.field_accessor self, :simple, :words, :hello, :ints, :complex, :shorts, :opt_string
37
- FIELDS = {
38
- SIMPLE => {:type => Thrift::Types::I32, :name => 'simple', :default => 53},
39
- WORDS => {:type => Thrift::Types::STRING, :name => 'words', :default => %q"words"},
40
- HELLO => {:type => Thrift::Types::STRUCT, :name => 'hello', :default => Hello.new({
41
- %q"greeting" => %q"hello, world!",
42
- }), :class => SpecNamespace::Hello},
43
- INTS => {:type => Thrift::Types::LIST, :name => 'ints', :default => [
44
- 1,
45
- 2,
46
- 2,
47
- 3,
48
- ], :element => {:type => Thrift::Types::I32}},
49
- COMPLEX => {:type => Thrift::Types::MAP, :name => 'complex', :key => {:type => Thrift::Types::I32}, :value => {:type => Thrift::Types::MAP, :key => {:type => Thrift::Types::STRING}, :value => {:type => Thrift::Types::DOUBLE}}},
50
- SHORTS => {:type => Thrift::Types::SET, :name => 'shorts', :default => Set.new([ 5,
51
- 17,
52
- 239,
53
- ]), :element => {:type => Thrift::Types::I16}},
54
- OPT_STRING => {:type => Thrift::Types::STRING, :name => 'opt_string', :optional => true}
55
- }
56
-
57
- def struct_fields; FIELDS; end
58
-
59
- def validate
60
- end
61
-
62
- end
63
-
64
- class BoolStruct
65
- include ::Thrift::Struct
66
- YESNO = 1
67
-
68
- Thrift::Struct.field_accessor self, :yesno
69
- FIELDS = {
70
- YESNO => {:type => Thrift::Types::BOOL, :name => 'yesno', :default => true}
71
- }
72
-
73
- def struct_fields; FIELDS; end
74
-
75
- def validate
76
- end
77
-
78
- end
79
-
80
- class SimpleList
81
- include ::Thrift::Struct
82
- BOOLS = 1
83
- BYTES = 2
84
- I16S = 3
85
- I32S = 4
86
- I64S = 5
87
- DOUBLES = 6
88
- STRINGS = 7
89
- MAPS = 8
90
- LISTS = 9
91
- SETS = 10
92
- HELLOS = 11
93
-
94
- Thrift::Struct.field_accessor self, :bools, :bytes, :i16s, :i32s, :i64s, :doubles, :strings, :maps, :lists, :sets, :hellos
95
- FIELDS = {
96
- BOOLS => {:type => Thrift::Types::LIST, :name => 'bools', :element => {:type => Thrift::Types::BOOL}},
97
- BYTES => {:type => Thrift::Types::LIST, :name => 'bytes', :element => {:type => Thrift::Types::BYTE}},
98
- I16S => {:type => Thrift::Types::LIST, :name => 'i16s', :element => {:type => Thrift::Types::I16}},
99
- I32S => {:type => Thrift::Types::LIST, :name => 'i32s', :element => {:type => Thrift::Types::I32}},
100
- I64S => {:type => Thrift::Types::LIST, :name => 'i64s', :element => {:type => Thrift::Types::I64}},
101
- DOUBLES => {:type => Thrift::Types::LIST, :name => 'doubles', :element => {:type => Thrift::Types::DOUBLE}},
102
- STRINGS => {:type => Thrift::Types::LIST, :name => 'strings', :element => {:type => Thrift::Types::STRING}},
103
- MAPS => {:type => Thrift::Types::LIST, :name => 'maps', :element => {:type => Thrift::Types::MAP, :key => {:type => Thrift::Types::I16}, :value => {:type => Thrift::Types::I16}}},
104
- LISTS => {:type => Thrift::Types::LIST, :name => 'lists', :element => {:type => Thrift::Types::LIST, :element => {:type => Thrift::Types::I16}}},
105
- SETS => {:type => Thrift::Types::LIST, :name => 'sets', :element => {:type => Thrift::Types::SET, :element => {:type => Thrift::Types::I16}}},
106
- HELLOS => {:type => Thrift::Types::LIST, :name => 'hellos', :element => {:type => Thrift::Types::STRUCT, :class => SpecNamespace::Hello}}
107
- }
108
-
109
- def struct_fields; FIELDS; end
110
-
111
- def validate
112
- end
113
-
114
- end
115
-
116
- class Xception < Thrift::Exception
117
- include ::Thrift::Struct
118
- MESSAGE = 1
119
- CODE = 2
120
-
121
- Thrift::Struct.field_accessor self, :message, :code
122
- FIELDS = {
123
- MESSAGE => {:type => Thrift::Types::STRING, :name => 'message'},
124
- CODE => {:type => Thrift::Types::I32, :name => 'code', :default => 1}
125
- }
126
-
127
- def struct_fields; FIELDS; end
128
-
129
- def validate
130
- end
131
-
132
- end
133
-
134
- end
@@ -1,31 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
- require 'thrift/transport/httpclient'
3
-
4
- class ThriftHTTPClientSpec < Spec::ExampleGroup
5
- include Thrift
6
-
7
- describe HTTPClient do
8
- before(:each) do
9
- @client = HTTPClient.new("http://my.domain.com/path/to/service")
10
- end
11
-
12
- it "should always be open" do
13
- @client.should be_open
14
- @client.close
15
- @client.should be_open
16
- end
17
-
18
- it "should post via HTTP and return the results" do
19
- @client.write "a test"
20
- @client.write " frame"
21
- Net::HTTP.should_receive(:new).with("my.domain.com", 80).and_return do
22
- mock("Net::HTTP").tee do |http|
23
- http.should_receive(:use_ssl=).with(false)
24
- http.should_receive(:post).with("/path/to/service", "a test frame", {"Content-Type"=>"application/x-thrift"}).and_return([nil, "data"])
25
- end
26
- end
27
- @client.flush
28
- @client.read(10).should == "data"
29
- end
30
- end
31
- end