protobuf-net / protobuf-net.Grpc

GRPC bindings for protobuf-net and grpc-dotnet
Other
858 stars 110 forks source link

Dapr support #172

Open tanekim88 opened 3 years ago

tanekim88 commented 3 years ago

Can protobuf-net be used for Dapr Grpc communication? An example would be greatly appreciated.

mgravell commented 3 years ago

I have absolutely no idea - can you point me at the relevant Dapr gRPC scenarios?

On Sat, 27 Mar 2021, 11:05 tanekim77, @.***> wrote:

Can protobuf-net be used for Dapr Grpc communication? An example would be greatly appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/protobuf-net/protobuf-net.Grpc/issues/172, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEHMEFUCI5J7U7ZSSQVADTFW3ZHANCNFSM4Z4ZWO3A .

tanekim88 commented 3 years ago

Dapr seems to be the next big thing pushed by Microsoft for clouds and microservices, and it provides Dapr client library that recognizes Grpc serialization. But as far as I know, Protobuf-net uses different serialization, so is likely that the client library may not recognize the Grpc of protobuf-net. However, it would be great if Protobuf-net also provides Dapr client library that can talk through Protobuf-net serialization, like Protobuf-net.dapr

mgravell commented 3 years ago

gRPC usually (not always) uses protobuf, which protobuf-net is fine with; any links I can peruse here?

On Sat, 27 Mar 2021, 20:34 tanekim77, @.***> wrote:

Dapr seems to be the next big thing pushed by Microsoft for clouds and microservices, and it provides Dapr client library that recognizes Grpc serialization. But as far as I know, Protobuf-net uses different serialization, so is likely that the client library may not recognize the Grpc of protobuf-net. However, it would be great if Protobuf-net also provides Dapr client library that can talk through Protobuf-net serialization, like Protobuf-net.dapr

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/protobuf-net/protobuf-net.Grpc/issues/172#issuecomment-808798832, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEHMDKJV3T4U4SEQ4YQQDTFY6NDANCNFSM4Z4ZWO3A .

tanekim88 commented 3 years ago

The link is here: https://dev.to/thangchung/net-grpc-server-on-dapr-runtime-3ba6

I know that Dapr's client library recognizes grpc server in the link, but I am not sure if it will for Protobuf-net.grpc server.

RemcoBlok commented 1 year ago

Example here https://github.com/RemcoBlok/dapr-service-invocation-grpc-code-first using dapr service invocation with protobuf-net. Could not see how to use with AddCodeFirstGrpcClient<T>() but registering a singleton works:

builder.Services.AddSingleton(_ =>
{
    return DaprClient.CreateInvocationInvoker("greeter-service").CreateGrpcService<IGreeterService>();
});

The DaprClient.CreateInvocationInvoker method says that the returned CallInvoker may be registered as singleton, but not sure if the same can be said for the IGreeterService instance.

mgravell commented 1 year ago

if the IGreeterService instance is a client, then it won't matter hugely, but: singleton should be fine if the invoker can be singleton (the client instance is just a thin veneer over the invoker)

SanYiKou commented 1 year ago

I have adopted @RemcoBlok's method for my project, and it works well for my self-defined services. However, the other gRPC services of Dapr are experiencing exceptions.

2023-06-20 16:23:34 [08:23:34 INF] Request starting HTTP/2 POST http://127.0.0.1:80/dapr.proto.runtime.v1.AppCallback/ListTopicSubscriptions application/grpc -
2023-06-20 16:23:34 [08:23:34 INF] Executing endpoint 'gRPC - Unimplemented service'
2023-06-20 16:23:34 [08:23:34 INF] Service 'dapr.proto.runtime.v1.AppCallback' is unimplemented.
2023-06-20 16:23:34 [08:23:34 INF] Executed endpoint 'gRPC - Unimplemented service'

The Dapr sidecar is throwing some exceptions. (I have configured the Pub/Sub building block on Dapr)

2023-06-20 16:23:34 time="2023-06-20T08:23:34.062920652Z" level=error msg="error getting topic list from app: rpc error: code = Unimplemented desc = Service is unimplemented." app_id=my-service-api instance=b2a6f7242482 scope=dapr.runtime type=log ver=1.8.3
2023-06-20 16:23:34 time="2023-06-20T08:23:34.062981123Z" level=error msg="error occurred while beginning pubsub my-pubsub: rpc error: code = Unimplemented desc = Service is unimplemented." app_id=my-service-api instance=b2a6f7242482 scope=dapr.runtime type=log ver=1.8.3
SanYiKou commented 1 year ago

I found that the reason is related to the dapr dotnet-sdk, and I need to manually implement the AppCallback service from dapr's .proto file. relate issues: https://github.com/dapr/dotnet-sdk/issues/493

zhoudi94 commented 1 year ago

I found that the reason is related to the dapr dotnet-sdk, and I need to manually implement the AppCallback service from dapr's .proto file. relate issues: dapr/dotnet-sdk#493

Hi , How to implement AppCallback manually?
protobuf-net and dapr Do you think they work well together? Any other questions?

mgravell commented 1 year ago

I have basically zero knowledge on Dapr; "I don't know". If there's specific things we can do in protobuf-net[.Grpc] : fine, but I simply don't have the capacity to do all the digging to find out what would be needed.