From cf010cdf9cb808ac872224b894bd5e1118ca76b7 Mon Sep 17 00:00:00 2001 From: David Chapman Date: Sat, 14 Sep 2024 15:02:28 +0100 Subject: [PATCH] GH-41347: [FlightRPC][C#] Allow hosting flight server in pre-Kestrel .net versions (#41348) ### Rationale for this change With the existing structure it is not possible to create a flight RPC service as a regular GRPC service, outside of AspNet.Core/Kestrel. This can be supported by changing the protection level of the generated classes and FlightServiceImplementation.cs ### What changes are included in this PR? Change protection level from internal to public for generated protocol files and FlightServiceImplementation.cs ### Are these changes tested? Confirmed that classes are public in the built assembly. ### Are there any user-facing changes? Generated protocol classes will become visible to end users. * GitHub Issue: #41347 Authored-by: David Chapman Signed-off-by: Curt Hagenlocher --- .../Apache.Arrow.Flight.csproj | 6 ++++- .../Server/GrpcCoreFlightServerExtensions.cs | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 csharp/src/Apache.Arrow.Flight/Server/GrpcCoreFlightServerExtensions.cs diff --git a/csharp/src/Apache.Arrow.Flight/Apache.Arrow.Flight.csproj b/csharp/src/Apache.Arrow.Flight/Apache.Arrow.Flight.csproj index a12f3f8249d4c..dc2e720313ba5 100644 --- a/csharp/src/Apache.Arrow.Flight/Apache.Arrow.Flight.csproj +++ b/csharp/src/Apache.Arrow.Flight/Apache.Arrow.Flight.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netstandard2.1 + netstandard2.0;netstandard2.1;net462 @@ -14,6 +14,10 @@ + + + + diff --git a/csharp/src/Apache.Arrow.Flight/Server/GrpcCoreFlightServerExtensions.cs b/csharp/src/Apache.Arrow.Flight/Server/GrpcCoreFlightServerExtensions.cs new file mode 100644 index 0000000000000..92c0af630a3fb --- /dev/null +++ b/csharp/src/Apache.Arrow.Flight/Server/GrpcCoreFlightServerExtensions.cs @@ -0,0 +1,24 @@ +#if NET46_OR_GREATER + +using Apache.Arrow.Flight.Protocol; +using Apache.Arrow.Flight.Server.Internal; +using Grpc.Core; + +namespace Apache.Arrow.Flight.Server +{ + public static class GrpcCoreFlightServerExtensions + { + /// + /// Create a ServerServiceDefinition for use with a Grpc.Core Server + // This allows running a flight server on pre-Kestrel .net Framework versions + /// + /// + /// + public static ServerServiceDefinition CreateServiceDefinition(this FlightServer flightServer) + { + return FlightService.BindService(new FlightServerImplementation(flightServer)); + } + } +} + +#endif