Module: Thrift

### Home Classes Methods

### In Files

- lib/thrift/client.rb
- lib/thrift/exceptions.rb
- lib/thrift/processor.rb
- lib/thrift/protocol/base_protocol.rb
- lib/thrift/protocol/binary_protocol.rb
- lib/thrift/protocol/binary_protocol_accelerated.rb
- lib/thrift/protocol/compact_protocol.rb
- lib/thrift/serializer/deserializer.rb
- lib/thrift/serializer/serializer.rb
- lib/thrift/server/base_server.rb
- lib/thrift/server/mongrel_http_server.rb
- lib/thrift/server/nonblocking_server.rb
- lib/thrift/server/simple_server.rb
- lib/thrift/server/thread_pool_server.rb
- lib/thrift/server/threaded_server.rb
- lib/thrift/struct.rb
- lib/thrift/struct_union.rb
- lib/thrift/transport/base_server_transport.rb
- lib/thrift/transport/base_transport.rb
- lib/thrift/transport/buffered_transport.rb
- lib/thrift/transport/framed_transport.rb
- lib/thrift/transport/http_client_transport.rb
- lib/thrift/transport/io_stream_transport.rb
- lib/thrift/transport/memory_buffer_transport.rb
- lib/thrift/transport/server_socket.rb
- lib/thrift/transport/socket.rb
- lib/thrift/transport/unix_server_socket.rb
- lib/thrift/transport/unix_socket.rb
- lib/thrift/types.rb
- lib/thrift/union.rb

### Namespace

- MODULE Thrift::Client
- MODULE Thrift::MessageTypes
- MODULE Thrift::Processor
- MODULE Thrift::Struct
- MODULE Thrift::Struct_Union
- MODULE Thrift::TransportUtils
- MODULE Thrift::Types
- CLASS Thrift::ApplicationException
- CLASS Thrift::BaseProtocol
- CLASS Thrift::BaseProtocolFactory
- CLASS Thrift::BaseServer
- CLASS Thrift::BaseServerTransport
- CLASS Thrift::BaseTransport
- CLASS Thrift::BaseTransportFactory
- CLASS Thrift::BinaryProtocol
- CLASS Thrift::BinaryProtocolAcceleratedFactory
- CLASS Thrift::BinaryProtocolFactory
- CLASS Thrift::BufferedTransport
- CLASS Thrift::BufferedTransportFactory
- CLASS Thrift::CompactProtocol
- CLASS Thrift::CompactProtocolFactory
- CLASS Thrift::Deserializer
- CLASS Thrift::Exception
- CLASS Thrift::FramedTransport
- CLASS Thrift::FramedTransportFactory
- CLASS Thrift::HTTPClientTransport
- CLASS Thrift::IOStreamTransport
- CLASS Thrift::MemoryBufferTransport
- CLASS Thrift::MongrelHTTPServer
- CLASS Thrift::NonblockingServer
- CLASS Thrift::ProtocolException
- CLASS Thrift::Serializer
- CLASS Thrift::ServerSocket
- CLASS Thrift::SimpleServer
- CLASS Thrift::Socket
- CLASS Thrift::ThreadPoolServer
- CLASS Thrift::ThreadedServer
- CLASS Thrift::TransportException
- CLASS Thrift::TypeError
- CLASS Thrift::UNIXServerSocket
- CLASS Thrift::UNIXSocket
- CLASS Thrift::Union

### Methods

- ::check_type
- ::type_name

### Files

- CHANGELOG
- README
- Makefile

### Class/Module Index

Quicksearch

- Thrift
- Thrift::ApplicationException
- Thrift::BaseProtocol
- Thrift::BaseProtocolFactory
- Thrift::BaseServer
- Thrift::BaseServerTransport
- Thrift::BaseTransport
- Thrift::BaseTransportFactory
- Thrift::BinaryProtocol
- Thrift::BinaryProtocolAcceleratedFactory
- Thrift::BinaryProtocolFactory
- Thrift::BufferedTransport
- Thrift::BufferedTransportFactory
- Thrift::Client
- Thrift::CompactProtocol
- Thrift::CompactProtocol::CompactTypes
- Thrift::CompactProtocolFactory
- Thrift::Deserializer
- Thrift::Exception
- Thrift::FramedTransport
- Thrift::FramedTransportFactory
- Thrift::HTTPClientTransport
- Thrift::IOStreamTransport
- Thrift::MemoryBufferTransport
- Thrift::MessageTypes
- Thrift::MongrelHTTPServer
- Thrift::MongrelHTTPServer::Handler
- Thrift::NonblockingServer
- Thrift::Processor
- Thrift::ProtocolException
- Thrift::Serializer
- Thrift::ServerSocket
- Thrift::SimpleServer
- Thrift::Socket
- Thrift::Struct
- Thrift::Struct_Union
- Thrift::ThreadPoolServer
- Thrift::ThreadedServer
- Thrift::TransportException
- Thrift::TransportUtils
- Thrift::TypeError
- Thrift::Types
- Thrift::UNIXServerSocket
- Thrift::UNIXSocket
- Thrift::Union
- Fixnum

No matching classes.

# Thrift

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Sticks a service on a URL, using mongrel to do the HTTP work

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Very very simple implementation of wrapping two objects, one with a read method and one with a write method, into a transport for thrift.

Assumes both objects are open, remain open, don't require flushing, etc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

### Attributes

type_checking[RW]

### Public Class Methods

check_type(value, field, name, skip_nil=true) click to toggle source

    # 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

type_name(type) click to toggle source

    # File lib/thrift/types.rb, line 86
    def self.type_name(type)
      Types.constants.each do |const|
        return "Types::#{const}" if Types.const_get(const) == type
      end
      nil
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.