question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide a way to create non-official gRPC client stub

See original GitHub issue

Currently, Armeria gRPC client factory use reflections to find a stub factory method or constructor from the specified client type. Armeria supports well-known client types already such as gRPC-Java, Reactive-gRPC, gRPC-Kotlin, and so on.

When users want to use a new gRPC client stub with Armeria gRPC client, we need to add a new reflection code to find ServiceDescriptor and a stub factory. I think this is not scalable.

If we introduce a GrpcStubFactory, users can easily integrate their gRPC stub with Armeria.

interface GrpcStubFactory {
    // Should return a ServiceDescriptor to use gRPC JSON foramt
    @Nullable
    ServiceDescriptor serviceDescriptor();

    Object stub(Channel channel);
}

MyGrpcStub client = 
        Clients.builder(grpcUrl)
               .options(GrpcClientOptions.STUB_FACTORY.newValue(new GrpcStubFactory {
                    @Override
                    public ServiceDescriptor serviceDescriptor() {
                        return MyGrpcStub.SERVICE;
                    }

                    @Override
                    public Object stub(Channel channel) {
                        return MyGrpcStub.stub(channel);
                    }
               })
               .build(MyGrpcStub.class);

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
trustincommented, Jan 21, 2021

Does it look weird if we support both SPI and GrpcClientOptions.CLIENT_STUB_FACTORY? gRPC-Java, gRPC-Kotlin, Reactive gRPC, and ScalaPB can be provided by SPI.

I think that’s fine.

0reactions
ikhooncommented, Jan 20, 2021

A generic type parameter could not be properly handled by SPI. In the following code, the IO type could be changed to other types by users’ choice.

GreetingServiceFs2Grpc.stub[IO](channel)

Does it look weird if we support both SPI and GrpcClientOptions.CLIENT_STUB_FACTORY? gRPC-Java, gRPC-Kotlin, Reactive gRPC, and ScalaPB can be provided by SPI.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Basics tutorial | Java - gRPC
This tutorial provides a basic Java programmer's introduction to working with gRPC. By walking through this example you'll learn how to:.
Read more >
Basics tutorial | Go - gRPC
This tutorial provides a basic Go programmer's introduction to working with gRPC. ... Generate server and client code using the protocol buffer compiler....
Read more >
Basics tutorial | Python - gRPC
This tutorial provides a basic Python programmer's introduction to working with gRPC. By walking through this example you'll learn how to:.
Read more >
So You Want to Optimize gRPC - Part 1
A common question with gRPC is how to make it fast. The gRPC library offers users ... We refer to the code called...
Read more >
Basics tutorial | C++ - gRPC
proto file and generate clients and servers in any of gRPC's supported languages, which in turn can be run in environments ranging from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found