-
Notifications
You must be signed in to change notification settings - Fork 821
Adds MapGrpcService overload for ServerServiceDefinition #2586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds MapGrpcService overload for ServerServiceDefinition #2586
Conversation
|
This is great and exactly what I needed. Currently, I copy the service code generated by |
…ttps://github.com/aka-nse/grpc-dotnet into feature/MapGrpcService-with-ServerServiceDefinition
…ttps://github.com/aka-nse/grpc-dotnet into feature/MapGrpcService-with-ServerServiceDefinition
|
Is this ever going to be implemented? |
|
@floozie |
|
Hi I refactored your PR to reduce duplication. See changes here: #2634. Are you ok with using those changes? |
This is a duplicate of #2535.
I made a serious operational error while tracking master, so I created a new pull request.
I apologize for the inconvenience.
Is your feature request related to a problem? Please describe.
This PR is implement for #2236.
ServerServiceDefinitionis defined in Grpc.Core.Api library, and it was a prefer way to implement gRPC server with Grpc.Core.In current grpc-dotnet, the server should be implemented on Asp.Net web application DI container via
GrpcEndpointRouteBuilderExtensions.MapGrpcServicegeneric method.The APIs in this proposal bridges legacy way into grpc-dotnet to enable to migrate easier.
Describe the solution you'd like
2 overloads of
GrpcEndpointRouteBuilderExtensions.MapGrpcServiceare added:This change enables to map gRPC services via
Grpc.Core.ServerServiceDefinition, therefore migration from Grpc.Core can be more easier.Changes in this PR
Grpc.Core.ApiGrpc.Core.ServerServiceDefinition.BindService(ServiceBinderBase)method as public*Grpc.AspNetCore.ServerMicrosoft.AspNetCore.Builder.GrpcEndpointRouteBuilderExtensionsclassMapGrpcService(this IEndpointRouteBuilder, ServerServiceDefinition)*MapGrpcService(this IEndpointRouteBuilder, Func<IServiceProvider, ServerServiceDefinition>)*ServerCallHandlerFactoryandServiceRouteBuilder(non-generic) onMicrosoft.Extensions.DependencyInjection.AddServiceOptionsmethod**Grpc.AspNetCore.Server.Internal.EndpointServiceBinderto bind methods inServerServiceDefinitioninto ASP.Net core web application server*Grpc.AspNetCore.Server.Internal.ServerCallHandlerFactoryclass*Grpc.AspNetCore.Server.Model.Internal.ServiceRouteBuilderclass*ServerCallHandlerBase*,UnaryServerCallhandler*,ServerStreamingServerCallHandler*,ClientStreamingServerCallHandler*, andDuplexStreamingServerCallHandler* classes inGrpc.AspNetCore.Server.Internal.CallHandlersnamespaceServerMethodInvokerBase*,UnaryServerMethodInvoker*,ServerStreamingServerMethodInvoker*,ClientStreamingServerMethodInvoker*, andDuplexStreamingServerMethodInvoker* classes inGrpc.Shared.ServernamespaceServerCallHandlerFactoryandServerCallHandlerFactory<TService>intoIServerCallHandlerFactory*test
MapGrpcServiceexamples
Grpc.AspNetCore.Server.Tests.TestObjects.Services.WithAttribute.GreeterWithAttribute.BindServicemethodDescribe alternatives you've considered
This commit contains concrete code as far as I can write, but I do not care about these implementations.
I welcome better ways to realize this suggestion.
Additional context
No response