grpc / grpc/grpc-dotnet

Map adhoc lambda expression to gRPC

Open
#111 7 comments 0 reactions 0 assignees View on GitHub
needs design
Dominant language
C#
Stars
4.5k
Forks
836
Avg merge
6d 3h
Merged PRs (30d)
7

Description

Today gRPC responses are always mapped to a service. What about adding some additional startup extension methods for mapping a lambda expression to a gRPC endpoint.

```cs
MapGrpcUnaryMethod(
this IEndpointRouteBuilder builder,
string serviceName,
string methodName,
UnaryCallHander handler);
```

```cs
routes.MapGrpcUnaryMethod("Greet.Greeter/SayHello", async (request, context) =>
{
return new HelloReply("Hello " + request.Message);
});
```

One issue to solve in the example above is serialization of the request and reply. That is defined on Grpc.Core's Method type, and with code-gen a marshaller is created over the top of a protobuf IMessage for the user. Need to think of a nice looking way to give that info to MapGrpcXXXMethod.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.