# # Autogenerated by Thrift Compiler (0.9.1) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # require 'thrift' require 'geong/geocoder/geocoder_types' module Geong module Geocoder module GeocoderService class Client include ::Thrift::Client def coordinates(address) send_coordinates(address) return recv_coordinates() end def send_coordinates(address) send_message('coordinates', Coordinates_args, :address => address) end def recv_coordinates() result = receive_message(Coordinates_result) return result.success unless result.success.nil? raise result.error unless result.error.nil? raise result.error2 unless result.error2.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'coordinates failed: unknown result') end def address(query) send_address(query) return recv_address() end def send_address(query) send_message('address', Address_args, :query => query) end def recv_address() result = receive_message(Address_result) return result.success unless result.success.nil? raise result.error unless result.error.nil? raise result.error2 unless result.error2.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'address failed: unknown result') end end class Processor include ::Thrift::Processor def process_coordinates(seqid, iprot, oprot) args = read_args(iprot, Coordinates_args) result = Coordinates_result.new() begin result.success = @handler.coordinates(args.address) rescue ::Geong::Geocoder::NoResultException => error result.error = error rescue ::Geong::Geocoder::TimeoutException => error2 result.error2 = error2 end write_result(result, oprot, 'coordinates', seqid) end def process_address(seqid, iprot, oprot) args = read_args(iprot, Address_args) result = Address_result.new() begin result.success = @handler.address(args.query) rescue ::Geong::Geocoder::NoResultException => error result.error = error rescue ::Geong::Geocoder::TimeoutException => error2 result.error2 = error2 end write_result(result, oprot, 'address', seqid) end end # HELPER FUNCTIONS AND STRUCTURES class Coordinates_args include ::Thrift::Struct, ::Thrift::Struct_Union ADDRESS = 1 FIELDS = { ADDRESS => {:type => ::Thrift::Types::STRING, :name => 'address'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class Coordinates_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 ERROR = 1 ERROR2 = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::Geong::Geocoder::Location}, ERROR => {:type => ::Thrift::Types::STRUCT, :name => 'error', :class => ::Geong::Geocoder::NoResultException}, ERROR2 => {:type => ::Thrift::Types::STRUCT, :name => 'error2', :class => ::Geong::Geocoder::TimeoutException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class Address_args include ::Thrift::Struct, ::Thrift::Struct_Union QUERY = 1 FIELDS = { QUERY => {:type => ::Thrift::Types::STRING, :name => 'query'} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class Address_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 ERROR = 1 ERROR2 = 2 FIELDS = { SUCCESS => {:type => ::Thrift::Types::STRING, :name => 'success'}, ERROR => {:type => ::Thrift::Types::STRUCT, :name => 'error', :class => ::Geong::Geocoder::NoResultException}, ERROR2 => {:type => ::Thrift::Types::STRUCT, :name => 'error2', :class => ::Geong::Geocoder::TimeoutException} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end end end end