# # Autogenerated by Thrift Compiler (0.9.2) # # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING # require 'thrift' require 'flume_types' module ThriftSourceProtocol class Client include ::Thrift::Client def append(event) send_append(event) return recv_append() end def send_append(event) send_message('append', Append_args, :event => event) end def recv_append() result = receive_message(Append_result) return result.success unless result.success.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'append failed: unknown result') end def appendBatch(events) send_appendBatch(events) return recv_appendBatch() end def send_appendBatch(events) send_message('appendBatch', AppendBatch_args, :events => events) end def recv_appendBatch() result = receive_message(AppendBatch_result) return result.success unless result.success.nil? raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'appendBatch failed: unknown result') end end class Processor include ::Thrift::Processor def process_append(seqid, iprot, oprot) args = read_args(iprot, Append_args) result = Append_result.new() result.success = @handler.append(args.event) write_result(result, oprot, 'append', seqid) end def process_appendBatch(seqid, iprot, oprot) args = read_args(iprot, AppendBatch_args) result = AppendBatch_result.new() result.success = @handler.appendBatch(args.events) write_result(result, oprot, 'appendBatch', seqid) end end # HELPER FUNCTIONS AND STRUCTURES class Append_args include ::Thrift::Struct, ::Thrift::Struct_Union EVENT = 1 FIELDS = { EVENT => {:type => ::Thrift::Types::STRUCT, :name => 'event', :class => ::ThriftFlumeEvent} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class Append_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success', :enum_class => ::Status} } def struct_fields; FIELDS; end def validate unless @success.nil? || ::Status::VALID_VALUES.include?(@success) raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field success!') end end ::Thrift::Struct.generate_accessors self end class AppendBatch_args include ::Thrift::Struct, ::Thrift::Struct_Union EVENTS = 1 FIELDS = { EVENTS => {:type => ::Thrift::Types::LIST, :name => 'events', :element => {:type => ::Thrift::Types::STRUCT, :class => ::ThriftFlumeEvent}} } def struct_fields; FIELDS; end def validate end ::Thrift::Struct.generate_accessors self end class AppendBatch_result include ::Thrift::Struct, ::Thrift::Struct_Union SUCCESS = 0 FIELDS = { SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success', :enum_class => ::Status} } def struct_fields; FIELDS; end def validate unless @success.nil? || ::Status::VALID_VALUES.include?(@success) raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Invalid value of field success!') end end ::Thrift::Struct.generate_accessors self end end