Class: Thrift::Processor::BinaryProcessor

Inherits:
BaseProcessor show all
Defined in:
lib/thrift/processor.rb

Direct Known Subclasses

BaseStreamProcessor

Instance Method Summary collapse

Constructor Details

#initialize(name, info, middleware, handler) ⇒ BinaryProcessor

Returns a new instance of BinaryProcessor.



219
220
221
222
223
224
225
226
227
228
# File 'lib/thrift/processor.rb', line 219

def initialize(name, info, middleware, handler)
  @middleware = middleware
  @handler = handler
  @arg_keys = info[:args]
  @void_result = info[:void_result]
  @result_klass = info[:result_klass]
  @exceptions = info[:exceptions]

  super name, info[:args_klass]
end

Instance Method Details

#process(seqid, iprot, oprot) ⇒ Object



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/thrift/processor.rb', line 230

def process(seqid, iprot, oprot)
  res = @middleware.handle_binary(@name, read_args(iprot)) do |args|
    execute(args)
  end

  write_result(res, oprot, seqid)

  true
rescue ApplicationException => e
  write_exception(e, oprot, @name, seqid)
  true
rescue StandardError => e
  write_exception(
    ApplicationException.new(
      ApplicationException::INTERNAL_ERROR,
      "Internal error processing #{@name}: #{e.class}: #{e}"
    ),
    oprot,
    @name,
    seqid
  )
  true
end