Skip to content

Support for Channel specification on ServiceClient.init #200

@rebello95

Description

@rebello95

Python's gRPC implementation allows for consumers to specify a channel when creating clients, like so:

def run():
    channel = grpc.insecure_channel('localhost:50051')
    my_stub = helloworld_pb2_grpc.FirstStub(channel)
    my_other_stub = helloworld_pb2_grpc.SomeOtherStub(channel)
    ...

The Objective-C implementation uses a singleton channel, where the current Swift implementation creates a new one every time.

Ideally, consumers would be able to specify their own Channel between multiple clients, which would alleviate the need for creating a new one each time:

/// Create a client with a pre-defined channel.
public init(channel: Channel) {
    gRPC.initialize()
    self.channel = channel
    self.metadata = Metadata()
}

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