line / armeria

Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
https://armeria.dev
Apache License 2.0
4.75k stars 899 forks source link

Service discovery with Nacos #5365

Open ikhoon opened 6 months ago

ikhoon commented 6 months ago

It would be useful to support service registration and discovery using Nacos.

KonaEspresso94 commented 6 months ago

Hi @ikhoon. I want to try this issue, can you assign this issue to me?

ikhoon commented 6 months ago

Sure. Thanks in advance! 🙇‍♂️

shalk commented 2 months ago

I am nacos contributor and i can give some advice or some help.

For Nacos, it provide nacos-client. Nacos client version 1.x is based on http. from version 2.x nacos client is based on grpc.

The current pr is good and is light. It look like the PR use armeria to create nacos http client.

If we need more nacos power (grpc for long connection) and nacos plugins (eg. auth plugin), it should use nacos client to build the nacos module. like zookeeper module

ikhoon commented 2 months ago

As Armeria provides various transport layers, we prefer to use our stack to support certain protocols.

If we need more nacos power (grpc for long connection)

It sounds like gRPC is a better choice. I was wondering if there was a way to replace the gRPC client with Armeria gRPC client.

If it is not supported, I am curious about what you think about providing an API that can replace the underlying client with an Armeria gRPC client. Armeria is a rich gRPC client with more features than its upstream clients.

shalk commented 2 months ago

As Armeria provides various transport layers, we prefer to use our stack to support certain protocols.

It make sense.

It sounds like gRPC is a better choice. I was wondering if there was a way to replace the gRPC client with Armeria gRPC client.

I can not replace the gRPC layer from the nacos-client by Armeria gRPC directly.

If it is not supported, I am curious about what you think about providing an API that can replace the underlying client with an Armeria gRPC client. Armeria is a rich gRPC client with more features than its upstream clients.

I think we can use Armeria gRPC to create NacosGrpcClient which support service register/list instance/watch etc.

The Nacos gRPC API is not document clear, I can give some info as follow:

  1. nacos grpc api is https://github.com/alibaba/nacos/blob/develop/api/src/main/proto/nacos_grpc_service.proto

  2. nacos use jackson to serialize the body to json , and then json to bytes in payload. https://github.com/alibaba/nacos/blob/develop/common/src/main/java/com/alibaba/nacos/common/remote/client/grpc/GrpcUtils.java#L75

Maybe i need try to create a prototype project (armeria-nacos-client) to test , make the api more clearly.

Should I need to try this ? @ikhoon

ikhoon commented 2 months ago

which use jackson to serialize the body to json and json to bytes in payload.

We have our own JSON marshaller which is more performant. https://github.com/line/armeria/blob/727ac8003dde3f665b80b17f25c71e48ccb7a340/grpc/src/main/java/com/linecorp/armeria/common/grpc/GrpcJsonMarshaller.java#L38-L38

I don't know what wire protocol is used for the JSON payload. Armeria gRPC client supports JSON out of the box. https://github.com/line/armeria/blob/727ac8003dde3f665b80b17f25c71e48ccb7a340/grpc/src/main/java/com/linecorp/armeria/common/grpc/GrpcSerializationFormats.java#L37-L40

Maybe i need try to create a prototype project (armeria-nacos-client) to test Should I need to try this

Yes, please. 🙏 I'm looking forward to the result. If we can fully support all Nacos features, that would be better.