-
Notifications
You must be signed in to change notification settings - Fork 794
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
base: master
Are you sure you want to change the base?
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 |
.github/workflows/test.yml
Outdated
@@ -15,7 +15,7 @@ jobs: | |||
|
|||
build: | |||
name: Basic Tests | |||
runs-on: ubuntu-latest | |||
runs-on: ubuntu-22.04 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to change to a specific version? Would the latest
cause any issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review.
This change does not appear to be something I directly intended, but rather seems to have been incorporated as a result of following changes made to the master branch.
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe update to net8.0
since net7.0
has been out of support
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review.
I understand that an update is necessary.
Other projects in examples/
are using .NET 9.0, so I am considering aligning with that. However, if you believe .NET 8.0 is preferable due to its longer support lifecycle, please let me know your thoughts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, think we could align with other examples 👍
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.
ServerServiceDefinition
is 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.MapGrpcService
generic 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.MapGrpcService
are 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.Api
Grpc.Core.ServerServiceDefinition.BindService(ServiceBinderBase)
method as public*Grpc.AspNetCore.Server
Microsoft.AspNetCore.Builder.GrpcEndpointRouteBuilderExtensions
classMapGrpcService(this IEndpointRouteBuilder, ServerServiceDefinition)
*MapGrpcService(this IEndpointRouteBuilder, Func<IServiceProvider, ServerServiceDefinition>)
*ServerCallHandlerFactory
andServiceRouteBuilder
(non-generic) onMicrosoft.Extensions.DependencyInjection.AddServiceOptions
method**Grpc.AspNetCore.Server.Internal.EndpointServiceBinder
to bind methods inServerServiceDefinition
into ASP.Net core web application server*Grpc.AspNetCore.Server.Internal.ServerCallHandlerFactory
class*Grpc.AspNetCore.Server.Model.Internal.ServiceRouteBuilder
class*ServerCallHandlerBase
*,UnaryServerCallhandler
*,ServerStreamingServerCallHandler
*,ClientStreamingServerCallHandler
*, andDuplexStreamingServerCallHandler
* classes inGrpc.AspNetCore.Server.Internal.CallHandlers
namespaceServerMethodInvokerBase
*,UnaryServerMethodInvoker
*,ServerStreamingServerMethodInvoker
*,ClientStreamingServerMethodInvoker
*, andDuplexStreamingServerMethodInvoker
* classes inGrpc.Shared.Server
namespaceServerCallHandlerFactory
andServerCallHandlerFactory<TService>
intoIServerCallHandlerFactory
*test
MapGrpcService
examples
Grpc.AspNetCore.Server.Tests.TestObjects.Services.WithAttribute.GreeterWithAttribute.BindService
methodDescribe 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