Class: Thrift::ThreadedServer

Inherits:
BaseServer show all
Defined in:
lib/thrift/server/threaded_server.rb

Instance Method Summary collapse

Methods inherited from BaseServer

#initialize

Constructor Details

This class inherits a constructor from Thrift::BaseServer

Instance Method Details

#serveObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/thrift/server/threaded_server.rb', line 25

def serve
  begin
    @server_transport.listen
    loop do
      begin
        client = @server_transport.accept
      rescue Errno::ECONNRESET, Errno::EPIPE
        next
      rescue => e
        next if defined?(OpenSSL::SSL::SSLError) && e.is_a?(OpenSSL::SSL::SSLError)
        raise
      end
      trans = @transport_factory.get_transport(client)
      prot = @protocol_factory.get_protocol(trans)
      Thread.new(prot, trans) do |p, t|
        begin
          loop do
            @processor.process(p, p)
          end
        rescue Thrift::TransportException, Thrift::ProtocolException
        ensure
          t.close
        end
      end
    end
  ensure
    @server_transport.close
  end
end

#to_sObject



55
56
57
# File 'lib/thrift/server/threaded_server.rb', line 55

def to_s
  "threaded(#{super.to_s})"
end