Module: Thrift
- Defined in:
- lib/thrift/bytes.rb,
lib/thrift/types.rb,
lib/thrift/union.rb,
lib/thrift/client.rb,
lib/thrift/struct.rb,
lib/thrift/processor.rb,
lib/thrift/exceptions.rb,
lib/thrift/struct_union.rb,
lib/thrift/transport/socket.rb,
lib/thrift/server/base_server.rb,
lib/thrift/server/simple_server.rb,
lib/thrift/transport/ssl_socket.rb,
lib/thrift/multiplexed_processor.rb,
lib/thrift/serializer/serializer.rb,
lib/thrift/transport/unix_socket.rb,
lib/thrift/protocol/base_protocol.rb,
lib/thrift/protocol/json_protocol.rb,
lib/thrift/server/threaded_server.rb,
lib/thrift/serializer/deserializer.rb,
lib/thrift/server/thin_http_server.rb,
lib/thrift/transport/server_socket.rb,
lib/thrift/protocol/binary_protocol.rb,
lib/thrift/transport/base_transport.rb,
lib/thrift/protocol/compact_protocol.rb,
lib/thrift/server/nonblocking_server.rb,
lib/thrift/server/thread_pool_server.rb,
lib/thrift/server/mongrel_http_server.rb,
lib/thrift/transport/framed_transport.rb,
lib/thrift/protocol/protocol_decorator.rb,
lib/thrift/transport/ssl_server_socket.rb,
lib/thrift/transport/buffered_transport.rb,
lib/thrift/transport/unix_server_socket.rb,
lib/thrift/protocol/multiplexed_protocol.rb,
lib/thrift/transport/io_stream_transport.rb,
lib/thrift/transport/base_server_transport.rb,
lib/thrift/transport/http_client_transport.rb,
lib/thrift/transport/memory_buffer_transport.rb,
lib/thrift/protocol/binary_protocol_accelerated.rb
Overview
The only change required for a transport to support BinaryProtocolAccelerated is to implement 2 methods:
* borrow(size), which takes an optional argument and returns atleast _size_ bytes from the transport,
or the default buffer size if no argument is given
* consume!(size), which removes size bytes from the front of the buffer
See MemoryBuffer and BufferedTransport for examples.
Defined Under Namespace
Modules: Bytes, Client, MessageTypes, Processor, ProtocolDecorator, Struct, Struct_Union, TransportUtils, Types Classes: ApplicationException, BaseProtocol, BaseProtocolFactory, BaseServer, BaseServerTransport, BaseTransport, BaseTransportFactory, BinaryProtocol, BinaryProtocolAcceleratedFactory, BinaryProtocolFactory, BufferedTransport, BufferedTransportFactory, CompactProtocol, CompactProtocolFactory, Deserializer, Exception, FramedTransport, FramedTransportFactory, HTTPClientTransport, IOStreamTransport, JSONContext, JSONListContext, JSONPairContext, JsonProtocol, JsonProtocolFactory, LookaheadReader, MemoryBufferTransport, MongrelHTTPServer, MultiplexedProcessor, MultiplexedProtocol, NonblockingServer, ProtocolException, SSLServerSocket, SSLSocket, Serializer, ServerSocket, SimpleServer, Socket, StoredMessageProtocol, ThinHTTPServer, ThreadPoolServer, ThreadedServer, TransportException, TypeError, UNIXServerSocket, UNIXSocket, Union
Class Attribute Summary collapse
-
.type_checking ⇒ Object
Returns the value of attribute type_checking.
Class Method Summary collapse
Class Attribute Details
.type_checking ⇒ Object
Returns the value of attribute type_checking.
40 41 42 |
# File 'lib/thrift/types.rb', line 40 def type_checking @type_checking end |
Class Method Details
.check_type(value, field, name, skip_nil = true) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/thrift/types.rb', line 46 def self.check_type(value, field, name, skip_nil=true) return if value.nil? and skip_nil klasses = case field[:type] when Types::VOID NilClass when Types::BOOL [TrueClass, FalseClass] when Types::BYTE, Types::I16, Types::I32, Types::I64 Integer when Types::DOUBLE Float when Types::STRING String when Types::STRUCT [Struct, Union] when Types::MAP Hash when Types::SET Set when Types::LIST Array end valid = klasses && [*klasses].any? { |klass| klass === value } raise TypeError, "Expected #{type_name(field[:type])}, received #{value.class} for field #{name}" unless valid # check elements now case field[:type] when Types::MAP value.each_pair do |k,v| check_type(k, field[:key], "#{name}.key", false) check_type(v, field[:value], "#{name}.value", false) end when Types::SET, Types::LIST value.each do |el| check_type(el, field[:element], "#{name}.element", false) end when Types::STRUCT raise TypeError, "Expected #{field[:class]}, received #{value.class} for field #{name}" unless field[:class] == value.class end end |