Skip to content

Allow registering multiple services in server application #40

@devholic

Description

@devholic

Currently, connect-python generated server constructor creates a new ConnectWSGI instance in each service function:

def wsgi_eliza_service(implementation: ElizaServiceProtocol) -> WSGIApplication:
    app = ConnectWSGI()
    app.register_unary_rpc("/connectrpc.eliza.v1.ElizaService/Say", implementation.say, eliza_pb2.SayRequest)
    ...
    return app

However, this makes hard to register multiple ConnectRPC services on a single WSGI application - scenarios like serving multiple services in a single instance or implementing health checking protocol.

I think it would be nice for the service constructor to take a ConnectWSGI instance as an argument to allow registering more than one service like below:

def wsgi_eliza_service(implementation: ElizaServiceProtocol, app = ConnectWSGI()) -> WSGIApplication:
    app.register_unary_rpc("/connectrpc.eliza.v1.ElizaService/Say", implementation.say, eliza_pb2.SayRequest)
    ...
    return app

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions