class ThriftServer::ThreadPoolServer
Attributes
port[RW]
Public Instance Methods
log(logger)
click to toggle source
# File lib/thrift_server/thread_pool_server.rb, line 40 def log(logger) subscribe LogSubscriber.new(logger) subscribe ThriftServer::LogSubscriber.new(logger) end
metrics(statsd)
click to toggle source
# File lib/thrift_server/thread_pool_server.rb, line 45 def metrics(statsd) subscribe MetricsSubscriber.new(statsd) subscribe ServerMetricsSubscriber.new(statsd) subscribe RpcMetricsSubscriber.new(statsd) end
protocol()
click to toggle source
# File lib/thrift_server/thread_pool_server.rb, line 55 def protocol @protocol_factory end
serve()
click to toggle source
NOTE: this a direct copy of the upstream code with instrumentation added.
# File lib/thrift_server/thread_pool_server.rb, line 74 def serve @server_transport.listen begin loop do @thread_q.push(:token) publish :thread_pool_server_pool_change, delta: 1 Thread.new do begin loop do client = @server_transport.accept remote_address = client.handle.remote_address publish :server_connection_opened, remote_address trans = @transport_factory.get_transport(client) prot = @protocol_factory.get_protocol(trans) begin loop do @processor.process(prot, prot) end rescue Thrift::TransportException, Thrift::ProtocolException => e publish :server_connection_closed, remote_address ensure trans.close end end rescue => e @exception_q.push(e) ensure publish :thread_pool_server_pool_change, delta: -1 @thread_q.pop # thread died! end end end ensure @server_transport.close end end
server_transport()
click to toggle source
# File lib/thrift_server/thread_pool_server.rb, line 63 def server_transport @server_transport end
start(dry_run: false)
click to toggle source
# File lib/thrift_server/thread_pool_server.rb, line 67 def start(dry_run: false) publish :server_start, self serve unless dry_run end
threads()
click to toggle source
# File lib/thrift_server/thread_pool_server.rb, line 51 def threads @thread_q.max end
transport()
click to toggle source
# File lib/thrift_server/thread_pool_server.rb, line 59 def transport @transport_factory end