Beispiel #1
0
def start_rpc_server(server_transport, server_service, server_handler, proto_factory=TBinaryProtocolFactory(strict_read=False,
                                                                                                            strict_write=False)):
    # setup server
    processor = TProcessor(server_service, server_handler)
    server = TSingleThreadedServer(processor, server_transport, daemon=True, iprot_factory=proto_factory)
    server.serve()
    return server
Beispiel #2
0
def make_server(service, handler,
                host="localhost", port=9090, unix_socket=None,
                proto_factory=TBinaryProtocolFactory(),
                trans_factory=TBufferedTransportFactory(),
                client_timeout=3000, certfile=None):
    processor = TProcessor(service, handler)

    if unix_socket:
        server_socket = TServerSocket(unix_socket=unix_socket)
        if certfile:
            warnings.warn("SSL only works with host:port, not unix_socket.")
    elif host and port:
        if certfile:
            server_socket = TSSLServerSocket(
                host=host, port=port, client_timeout=client_timeout,
                certfile=certfile)
        else:
            server_socket = TServerSocket(
                host=host, port=port, client_timeout=client_timeout)
    else:
        raise ValueError("Either host/port or unix_socket must be provided.")

    server = TThreadedServer(processor, server_socket,
                             iprot_factory=proto_factory,
                             itrans_factory=trans_factory)
    return server
Beispiel #3
0
def make_server(service,
                handler,
                host,
                port,
                proto_factory=TBinaryProtocolFactory(),
                trans_factory=TBufferedTransportFactory()):
    processor = TProcessor(service, handler)
    server = THttpServer(processor, (host, port),
                         itrans_factory=trans_factory,
                         iprot_factory=proto_factory)
    return server
Beispiel #4
0
def _rpc_server(server_socket, server_service, client_service, server_handler_factory, proto_factory):
    client_socket, address = server_socket.accept()

    client_transport, server_transport = _create_client_server_transports(client_socket)

    client_protocol = proto_factory.get_protocol(client_transport)

    rpc_client = TSyncClient(client_service, client_protocol)

    server_handler = server_handler_factory(rpc_client)

    # setup server
    processor = TProcessor(server_service, server_handler)
    server = TSingleThreadedServer(processor, server_transport, daemon=True, iprot_factory=proto_factory)
    server.serve()
Beispiel #5
0
def make_server(service,
                handler,
                host="localhost",
                port=9090,
                unix_socket=None,
                proto_factory=TBinaryProtocolFactory(),
                trans_factory=TBufferedTransportFactory()):
    processor = TProcessor(service, handler)
    if unix_socket:
        server_socket = TServerSocket(unix_socket=unix_socket)
    elif host and port:
        server_socket = TServerSocket(host=host, port=port)
    else:
        raise ValueError("Either host/port or unix_socket must be provided.")

    server = TThreadedServer(processor,
                             server_socket,
                             iprot_factory=proto_factory,
                             itrans_factory=trans_factory)
    return server