示例#1
0
        processor = ThriftTest.ContextProcessor(
            TestContextHandler(options.port))
    else:
        processor = ThriftTest.Processor(TestHandler())

    if options.multiple:
        processor = TMultiplexedProcessor.TMultiplexedProcessor()
        if options.context:
            processor.registerProcessor(
                "ThriftTest",
                ThriftTest.ContextProcessor(TestContextHandler(options.port)))
            processor.registerProcessor(
                "SecondService",
                SecondService.ContextProcessor(SecondContextHandler()))
        else:
            processor.registerProcessor("ThriftTest",
                                        ThriftTest.Processor(TestHandler()))
            processor.registerProcessor(
                "SecondService", SecondService.Processor(SecondHandler()))

    server = TCppServer.TCppServer(processor)
    server.setPort(options.port)

    if options.header:
        server.processor.setEventHandler(HeaderEventHandler())
    elif options.context:
        server.processor.setEventHandler(ContextEventHandler())
    server.setServerEventHandler(event_handler)

    server.serve()
示例#2
0
if len(args) > 1:
    raise AssertionError(
        'Only one server type may be specified, not multiple types.')
server_type = args[0]

# Set up the handler and processor objects
if not options.multiple:
    handler = TestHandler()
    processor = ThriftTest.Processor(handler)
else:
    processor = TMultiplexedProcessor.TMultiplexedProcessor()
    handler = TestHandler()
    processor.registerProcessor("ThriftTest", ThriftTest.Processor(handler))
    handler = SecondHandler()
    processor.registerProcessor("SecondService",
                                SecondService.Processor(handler))

# Handle THttpServer as a special case
if server_type == 'THttpServer':
    server = THttpServer.THttpServer(processor, ('', options.port), pfactory)
    server.serve()
    sys.exit(0)

# set up server transport and transport factory
host = None
if options.ssl:
    from thrift.transport import TSSLSocket
    transport = TSSLSocket.TSSLServerSocket(host,
                                            options.port,
                                            certfile='../keys/server.pem')
else: