Class: ThriftServer::ThreadedServer
- Inherits:
-
Thrift::ThreadedServer
- Object
- Thrift::ThreadedServer
- ThriftServer::ThreadedServer
- Extended by:
- Forwardable
- Defined in:
- lib/thrift_server/threaded_server.rb
Defined Under Namespace
Classes: LogSubscriber
Instance Attribute Summary collapse
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
- #log(logger) ⇒ Object
- #metrics(statsd) ⇒ Object
- #protocol ⇒ Object
-
#serve ⇒ Object
NOTE: this is a copy of the upstream code with instrumentation added.
- #server_transport ⇒ Object
- #start(dry_run: false) ⇒ Object
- #transport ⇒ Object
Instance Attribute Details
#port ⇒ Object
Returns the value of attribute port.
26 27 28 |
# File 'lib/thrift_server/threaded_server.rb', line 26 def port @port end |
Instance Method Details
#log(logger) ⇒ Object
28 29 30 31 |
# File 'lib/thrift_server/threaded_server.rb', line 28 def log(logger) subscribe LogSubscriber.new(logger) subscribe ThriftServer::LogSubscriber.new(logger) end |
#metrics(statsd) ⇒ Object
33 34 35 36 |
# File 'lib/thrift_server/threaded_server.rb', line 33 def metrics(statsd) subscribe ServerMetricsSubscriber.new(statsd) subscribe RpcMetricsSubscriber.new(statsd) end |
#protocol ⇒ Object
38 39 40 |
# File 'lib/thrift_server/threaded_server.rb', line 38 def protocol @protocol_factory end |
#serve ⇒ Object
NOTE: this is a copy of the upstream code with instrumentation added.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/thrift_server/threaded_server.rb', line 57 def serve begin @server_transport.listen 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) Thread.new(prot, trans) do |p, t| begin loop do @processor.process(p, p) end rescue Thrift::TransportException, Thrift::ProtocolException ensure publish :server_connection_closed, remote_address t.close end end end ensure @server_transport.close end end |
#server_transport ⇒ Object
46 47 48 |
# File 'lib/thrift_server/threaded_server.rb', line 46 def server_transport @server_transport end |
#start(dry_run: false) ⇒ Object
50 51 52 53 54 |
# File 'lib/thrift_server/threaded_server.rb', line 50 def start(dry_run: false) publish :server_start, self serve unless dry_run end |
#transport ⇒ Object
42 43 44 |
# File 'lib/thrift_server/threaded_server.rb', line 42 def transport @transport_factory end |