diff options
Diffstat (limited to 'src')
23 files changed, 274 insertions, 70 deletions
diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index 48157033db..7b97ed3e2c 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -308,12 +308,12 @@ void GenerateServiceDescriptorProperty(Printer *out, out->Print("\n"); } -void GenerateServerClass(Printer *out, const ServiceDescriptor *service) { +void GenerateServerClass(Printer* out, const ServiceDescriptor *service) { out->Print( "/// <summary>Base class for server-side implementations of " "$servicename$</summary>\n", "servicename", GetServiceClassName(service)); - out->Print("public abstract class $name$\n", "name", + out->Print("public abstract partial class $name$\n", "name", GetServerClassName(service)); out->Print("{\n"); out->Indent(); @@ -341,11 +341,12 @@ void GenerateServerClass(Printer *out, const ServiceDescriptor *service) { out->Print("\n"); } -void GenerateClientStub(Printer *out, const ServiceDescriptor *service) { - out->Print("/// <summary>Client for $servicename$</summary>\n", "servicename", - GetServiceClassName(service)); - out->Print("public class $name$ : ClientBase<$name$>\n", "name", - GetClientClassName(service)); +void GenerateClientStub(Printer* out, const ServiceDescriptor *service) { + out->Print("/// <summary>Client for $servicename$</summary>\n", + "servicename", GetServiceClassName(service)); + out->Print( + "public partial class $name$ : ClientBase<$name$>\n", + "name", GetClientClassName(service)); out->Print("{\n"); out->Indent(); @@ -549,7 +550,7 @@ void GenerateService(Printer *out, const ServiceDescriptor *service, bool generate_client, bool generate_server, bool internal_access) { GenerateDocCommentBody(out, service); - out->Print("$access_level$ static class $classname$\n", "access_level", + out->Print("$access_level$ static partial class $classname$\n", "access_level", GetAccessLevel(internal_access), "classname", GetServiceClassName(service)); out->Print("{\n"); diff --git a/src/csharp/Grpc.Auth/project.json b/src/csharp/Grpc.Auth/project.json index 595e29f50a..4052ec8398 100644 --- a/src/csharp/Grpc.Auth/project.json +++ b/src/csharp/Grpc.Auth/project.json @@ -15,7 +15,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Core.Tests/project.json b/src/csharp/Grpc.Core.Tests/project.json index faf28dcee8..509084a71a 100644 --- a/src/csharp/Grpc.Core.Tests/project.json +++ b/src/csharp/Grpc.Core.Tests/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Core/project.json b/src/csharp/Grpc.Core/project.json index 80f59b2af6..4405ecc5a2 100644 --- a/src/csharp/Grpc.Core/project.json +++ b/src/csharp/Grpc.Core/project.json @@ -27,7 +27,6 @@ "embed": [ "../../../etc/roots.pem" ], "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true }, "dependencies": { diff --git a/src/csharp/Grpc.Examples.MathClient/project.json b/src/csharp/Grpc.Examples.MathClient/project.json index 628f532966..9a8880b5d4 100644 --- a/src/csharp/Grpc.Examples.MathClient/project.json +++ b/src/csharp/Grpc.Examples.MathClient/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Examples.MathServer/project.json b/src/csharp/Grpc.Examples.MathServer/project.json index 628f532966..9a8880b5d4 100644 --- a/src/csharp/Grpc.Examples.MathServer/project.json +++ b/src/csharp/Grpc.Examples.MathServer/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Examples.Tests/project.json b/src/csharp/Grpc.Examples.Tests/project.json index 0109617e6b..3e130beeac 100644 --- a/src/csharp/Grpc.Examples.Tests/project.json +++ b/src/csharp/Grpc.Examples.Tests/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Examples/MathGrpc.cs b/src/csharp/Grpc.Examples/MathGrpc.cs index d6ba61e7dc..21727d57c6 100644 --- a/src/csharp/Grpc.Examples/MathGrpc.cs +++ b/src/csharp/Grpc.Examples/MathGrpc.cs @@ -38,7 +38,7 @@ using System.Threading.Tasks; using Grpc.Core; namespace Math { - public static class Math + public static partial class Math { static readonly string __ServiceName = "math.Math"; @@ -82,7 +82,7 @@ namespace Math { } /// <summary>Base class for server-side implementations of Math</summary> - public abstract class MathBase + public abstract partial class MathBase { /// <summary> /// Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient @@ -126,7 +126,7 @@ namespace Math { } /// <summary>Client for Math</summary> - public class MathClient : ClientBase<MathClient> + public partial class MathClient : ClientBase<MathClient> { /// <summary>Creates a new client for Math</summary> /// <param name="channel">The channel to use to make remote calls.</param> diff --git a/src/csharp/Grpc.HealthCheck.Tests/project.json b/src/csharp/Grpc.HealthCheck.Tests/project.json index 66dcd79a39..addc782afe 100644 --- a/src/csharp/Grpc.HealthCheck.Tests/project.json +++ b/src/csharp/Grpc.HealthCheck.Tests/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs index b2a35a79be..03381f0b88 100644 --- a/src/csharp/Grpc.HealthCheck/HealthGrpc.cs +++ b/src/csharp/Grpc.HealthCheck/HealthGrpc.cs @@ -38,7 +38,7 @@ using System.Threading.Tasks; using Grpc.Core; namespace Grpc.Health.V1 { - public static class Health + public static partial class Health { static readonly string __ServiceName = "grpc.health.v1.Health"; @@ -59,7 +59,7 @@ namespace Grpc.Health.V1 { } /// <summary>Base class for server-side implementations of Health</summary> - public abstract class HealthBase + public abstract partial class HealthBase { public virtual global::System.Threading.Tasks.Task<global::Grpc.Health.V1.HealthCheckResponse> Check(global::Grpc.Health.V1.HealthCheckRequest request, ServerCallContext context) { @@ -69,7 +69,7 @@ namespace Grpc.Health.V1 { } /// <summary>Client for Health</summary> - public class HealthClient : ClientBase<HealthClient> + public partial class HealthClient : ClientBase<HealthClient> { /// <summary>Creates a new client for Health</summary> /// <param name="channel">The channel to use to make remote calls.</param> diff --git a/src/csharp/Grpc.HealthCheck/project.json b/src/csharp/Grpc.HealthCheck/project.json index 9d631229d8..8f1237d003 100644 --- a/src/csharp/Grpc.HealthCheck/project.json +++ b/src/csharp/Grpc.HealthCheck/project.json @@ -15,7 +15,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.Client/project.json b/src/csharp/Grpc.IntegrationTesting.Client/project.json index 1b900c8af3..ad81cbc48b 100644 --- a/src/csharp/Grpc.IntegrationTesting.Client/project.json +++ b/src/csharp/Grpc.IntegrationTesting.Client/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json b/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json index fe200f8d44..2c7643b74f 100644 --- a/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json +++ b/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.Server/project.json b/src/csharp/Grpc.IntegrationTesting.Server/project.json index 1b900c8af3..ad81cbc48b 100644 --- a/src/csharp/Grpc.IntegrationTesting.Server/project.json +++ b/src/csharp/Grpc.IntegrationTesting.Server/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.StressClient/project.json b/src/csharp/Grpc.IntegrationTesting.StressClient/project.json index 1b900c8af3..ad81cbc48b 100644 --- a/src/csharp/Grpc.IntegrationTesting.StressClient/project.json +++ b/src/csharp/Grpc.IntegrationTesting.StressClient/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs index bcd7e3c040..d0bf0afc1d 100644 --- a/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs @@ -44,7 +44,7 @@ using System.Threading.Tasks; using Grpc.Core; namespace Grpc.Testing { - public static class MetricsService + public static partial class MetricsService { static readonly string __ServiceName = "grpc.testing.MetricsService"; @@ -73,7 +73,7 @@ namespace Grpc.Testing { } /// <summary>Base class for server-side implementations of MetricsService</summary> - public abstract class MetricsServiceBase + public abstract partial class MetricsServiceBase { /// <summary> /// Returns the values of all the gauges that are currently being maintained by @@ -95,7 +95,7 @@ namespace Grpc.Testing { } /// <summary>Client for MetricsService</summary> - public class MetricsServiceClient : ClientBase<MetricsServiceClient> + public partial class MetricsServiceClient : ClientBase<MetricsServiceClient> { /// <summary>Creates a new client for MetricsService</summary> /// <param name="channel">The channel to use to make remote calls.</param> diff --git a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs index 848dd04fa7..3cc4ed9f3c 100644 --- a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs @@ -40,7 +40,7 @@ using System.Threading.Tasks; using Grpc.Core; namespace Grpc.Testing { - public static class BenchmarkService + public static partial class BenchmarkService { static readonly string __ServiceName = "grpc.testing.BenchmarkService"; @@ -68,7 +68,7 @@ namespace Grpc.Testing { } /// <summary>Base class for server-side implementations of BenchmarkService</summary> - public abstract class BenchmarkServiceBase + public abstract partial class BenchmarkServiceBase { /// <summary> /// One request followed by one response. @@ -91,7 +91,7 @@ namespace Grpc.Testing { } /// <summary>Client for BenchmarkService</summary> - public class BenchmarkServiceClient : ClientBase<BenchmarkServiceClient> + public partial class BenchmarkServiceClient : ClientBase<BenchmarkServiceClient> { /// <summary>Creates a new client for BenchmarkService</summary> /// <param name="channel">The channel to use to make remote calls.</param> @@ -177,7 +177,7 @@ namespace Grpc.Testing { } } - public static class WorkerService + public static partial class WorkerService { static readonly string __ServiceName = "grpc.testing.WorkerService"; @@ -224,7 +224,7 @@ namespace Grpc.Testing { } /// <summary>Base class for server-side implementations of WorkerService</summary> - public abstract class WorkerServiceBase + public abstract partial class WorkerServiceBase { /// <summary> /// Start server with specified workload. @@ -271,7 +271,7 @@ namespace Grpc.Testing { } /// <summary>Client for WorkerService</summary> - public class WorkerServiceClient : ClientBase<WorkerServiceClient> + public partial class WorkerServiceClient : ClientBase<WorkerServiceClient> { /// <summary>Creates a new client for WorkerService</summary> /// <param name="channel">The channel to use to make remote calls.</param> diff --git a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs index 8d649bf5c5..43dbc2865f 100644 --- a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs @@ -45,7 +45,7 @@ namespace Grpc.Testing { /// A simple service to test the various types of RPCs and experiment with /// performance with various types of payload. /// </summary> - public static class TestService + public static partial class TestService { static readonly string __ServiceName = "grpc.testing.TestService"; @@ -120,7 +120,7 @@ namespace Grpc.Testing { } /// <summary>Base class for server-side implementations of TestService</summary> - public abstract class TestServiceBase + public abstract partial class TestServiceBase { /// <summary> /// One empty request followed by one empty response. @@ -199,7 +199,7 @@ namespace Grpc.Testing { } /// <summary>Client for TestService</summary> - public class TestServiceClient : ClientBase<TestServiceClient> + public partial class TestServiceClient : ClientBase<TestServiceClient> { /// <summary>Creates a new client for TestService</summary> /// <param name="channel">The channel to use to make remote calls.</param> @@ -441,7 +441,7 @@ namespace Grpc.Testing { /// A simple service NOT implemented at servers so clients can test for /// that case. /// </summary> - public static class UnimplementedService + public static partial class UnimplementedService { static readonly string __ServiceName = "grpc.testing.UnimplementedService"; @@ -461,7 +461,7 @@ namespace Grpc.Testing { } /// <summary>Base class for server-side implementations of UnimplementedService</summary> - public abstract class UnimplementedServiceBase + public abstract partial class UnimplementedServiceBase { /// <summary> /// A call that no server should implement @@ -474,7 +474,7 @@ namespace Grpc.Testing { } /// <summary>Client for UnimplementedService</summary> - public class UnimplementedServiceClient : ClientBase<UnimplementedServiceClient> + public partial class UnimplementedServiceClient : ClientBase<UnimplementedServiceClient> { /// <summary>Creates a new client for UnimplementedService</summary> /// <param name="channel">The channel to use to make remote calls.</param> @@ -542,7 +542,7 @@ namespace Grpc.Testing { /// <summary> /// A service used to control reconnect server. /// </summary> - public static class ReconnectService + public static partial class ReconnectService { static readonly string __ServiceName = "grpc.testing.ReconnectService"; @@ -571,7 +571,7 @@ namespace Grpc.Testing { } /// <summary>Base class for server-side implementations of ReconnectService</summary> - public abstract class ReconnectServiceBase + public abstract partial class ReconnectServiceBase { public virtual global::System.Threading.Tasks.Task<global::Grpc.Testing.Empty> Start(global::Grpc.Testing.ReconnectParams request, ServerCallContext context) { @@ -586,7 +586,7 @@ namespace Grpc.Testing { } /// <summary>Client for ReconnectService</summary> - public class ReconnectServiceClient : ClientBase<ReconnectServiceClient> + public partial class ReconnectServiceClient : ClientBase<ReconnectServiceClient> { /// <summary>Creates a new client for ReconnectService</summary> /// <param name="channel">The channel to use to make remote calls.</param> diff --git a/src/csharp/Grpc.IntegrationTesting/project.json b/src/csharp/Grpc.IntegrationTesting/project.json index 0225abb414..e47b5953da 100644 --- a/src/csharp/Grpc.IntegrationTesting/project.json +++ b/src/csharp/Grpc.IntegrationTesting/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat new file mode 100755 index 0000000000..b0e358fdff --- /dev/null +++ b/src/csharp/build_packages_dotnetcli.bat @@ -0,0 +1,79 @@ +@rem Copyright 2016, Google Inc. +@rem All rights reserved. +@rem +@rem Redistribution and use in source and binary forms, with or without +@rem modification, are permitted provided that the following conditions are +@rem met: +@rem +@rem * Redistributions of source code must retain the above copyright +@rem notice, this list of conditions and the following disclaimer. +@rem * Redistributions in binary form must reproduce the above +@rem copyright notice, this list of conditions and the following disclaimer +@rem in the documentation and/or other materials provided with the +@rem distribution. +@rem * Neither the name of Google Inc. nor the names of its +@rem contributors may be used to endorse or promote products derived from +@rem this software without specific prior written permission. +@rem +@rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +@rem "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +@rem LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +@rem A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +@rem OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +@rem SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +@rem LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +@rem DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +@rem THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +@rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +@rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +@rem Current package versions +set VERSION=1.0.1 +set PROTOBUF_VERSION=3.0.0 + +@rem Adjust the location of nuget.exe +set NUGET=C:\nuget\nuget.exe +set DOTNET=C:\dotnet\dotnet.exe + +set -ex + +mkdir -p ..\..\artifacts\ + +@rem Collect the artifacts built by the previous build step if running on Jenkins +@rem TODO(jtattermusch): is there a better way to do this? +xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=windows\artifacts\* nativelibs\windows_x86\ +xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=windows\artifacts\* nativelibs\windows_x64\ +xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=linux\artifacts\* nativelibs\linux_x86\ +xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=linux\artifacts\* nativelibs\linux_x64\ +xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=macos\artifacts\* nativelibs\macosx_x86\ +xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=macos\artifacts\* nativelibs\macosx_x64\ + +@rem Collect protoc artifacts built by the previous build step +xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=windows\artifacts\* protoc_plugins\windows_x86\ +xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=windows\artifacts\* protoc_plugins\windows_x64\ +xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=linux\artifacts\* protoc_plugins\linux_x86\ +xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=linux\artifacts\* protoc_plugins\linux_x64\ +xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=macos\artifacts\* protoc_plugins\macosx_x86\ +xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=macos\artifacts\* protoc_plugins\macosx_x64\ + +%DOTNET% restore . || goto :error + +%DOTNET% pack --configuration Release Grpc.Core\project.json --output ..\..\artifacts || goto :error +%DOTNET% pack --configuration Release Grpc.Auth\project.json --output ..\..\artifacts || goto :error +%DOTNET% pack --configuration Release Grpc.HealthCheck\project.json --output ..\..\artifacts || goto :error + +%NUGET% pack Grpc.nuspec -Version "1.0.1" -OutputDirectory ..\..\artifacts || goto :error +%NUGET% pack Grpc.Tools.nuspec -Version "1.0.1" -OutputDirectory ..\..\artifacts + +@rem copy resulting nuget packages to artifacts directory +xcopy /Y /I *.nupkg ..\..\artifacts\ || goto :error + +@rem create a zipfile with the artifacts as well +powershell -Command "Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('..\..\artifacts', 'csharp_nugets_windows_dotnetcli.zip');" +xcopy /Y /I csharp_nugets_windows_dotnetcli.zip ..\..\artifacts\ || goto :error + +goto :EOF + +:error +echo Failed! +exit /b %errorlevel% diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index 526bd9e14f..4e4062bafc 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -927,10 +927,16 @@ class Server(six.with_metaclass(abc.ABCMeta)): passed in a previous call will not have the effect of stopping the server later. + This method does not block for any significant length of time. If None is + passed as the grace value, existing RPCs are immediately aborted and this + method blocks until this Server is completely stopped. + Args: - grace: A duration of time in seconds to allow existing RPCs to complete - before being aborted by this Server's stopping. If None, this method - will block until the server is completely stopped. + grace: A duration of time in seconds or None. If a duration of time in + seconds, the time to allow existing RPCs to complete before being + aborted by this Server's stopping. If None, all RPCs will be aborted + immediately and this method will block until this Server is completely + stopped. Returns: A threading.Event that will be set when this Server has completely diff --git a/src/ruby/lib/grpc/generic/rpc_server.rb b/src/ruby/lib/grpc/generic/rpc_server.rb index 57f99c8ce6..ae07439fcf 100644 --- a/src/ruby/lib/grpc/generic/rpc_server.rb +++ b/src/ruby/lib/grpc/generic/rpc_server.rb @@ -35,6 +35,7 @@ require 'concurrent' # GRPC contains the General RPC module. module GRPC + # RpcServer hosts a number of services and makes them available on the # network. class RpcServer @@ -50,8 +51,8 @@ module GRPC # Default minimum size of the thread pool is 5 DEFAULT_MIN_POOL_SIZE = 5 - # Default max_waiting_requests size is 60 - DEFAULT_MAX_WAITING_REQUESTS = 60 + # Deprecated due to internal changes to the thread pool + DEFAULT_MAX_WAITING_REQUESTS = 20 # Default poll period is 1s # Used for grpc server shutdown and thread pool shutdown timeouts @@ -76,11 +77,11 @@ module GRPC # instance. # # * pool_size: the maximum size of the thread pool that the server's - # thread pool can reach. + # thread pool can reach. No more concurrent requests can be made than + # the size of the thread pool # - # * max_waiting_requests: the maximum number of requests that are not - # being handled to allow. When this limit is exceeded, the server responds - # with not available to new requests + # * max_waiting_requests: Deprecated due to internal changes to the thread + # pool. This is still an argument for compatibility but is ignored. # # * poll_period: when present, the server polls for new events with this # period @@ -236,12 +237,8 @@ module GRPC # Sends RESOURCE_EXHAUSTED if there are too many unprocessed jobs def available?(an_rpc) - jobs_count, max = @pool.queue_length, @pool.max_queue - GRPC.logger.info("waiting: #{jobs_count}, max: #{max}") - - # remaining capacity for ThreadPoolExecutors is -1 if unbounded - return an_rpc if @pool.remaining_capacity != 0 - GRPC.logger.warn("NOT AVAILABLE: too many jobs_waiting: #{an_rpc}") + return an_rpc if @pool.ready_for_work? + GRPC.logger.warn('no free worker threads currently') noop = proc { |x| x } # Create a new active call that knows that metadata hasn't been diff --git a/src/ruby/spec/generic/rpc_server_pool_spec.rb b/src/ruby/spec/generic/rpc_server_pool_spec.rb new file mode 100644 index 0000000000..48ccaee510 --- /dev/null +++ b/src/ruby/spec/generic/rpc_server_pool_spec.rb @@ -0,0 +1,144 @@ +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +require 'grpc' + +Thread.abort_on_exception = true + +describe GRPC::Pool do + Pool = GRPC::Pool + + describe '#new' do + it 'raises if a non-positive size is used' do + expect { Pool.new(0) }.to raise_error + expect { Pool.new(-1) }.to raise_error + expect { Pool.new(Object.new) }.to raise_error + end + + it 'is constructed OK with a positive size' do + expect { Pool.new(1) }.not_to raise_error + end + end + + describe '#ready_for_work?' do + it 'before start it is not ready' do + p = Pool.new(1) + expect(p.ready_for_work?).to be(false) + end + + it 'it stops being ready after all workers jobs waiting or running' do + p = Pool.new(5) + p.start + job = proc { sleep(3) } # sleep so workers busy when done scheduling + 5.times do + expect(p.ready_for_work?).to be(true) + p.schedule(&job) + end + expect(p.ready_for_work?).to be(false) + end + + it 'it becomes ready again after jobs complete' do + p = Pool.new(5) + p.start + job = proc {} + 5.times do + expect(p.ready_for_work?).to be(true) + p.schedule(&job) + end + expect(p.ready_for_work?).to be(false) + sleep 5 # give the pool time do get at least one task done + expect(p.ready_for_work?).to be(true) + end + end + + describe '#schedule' do + it 'return if the pool is already stopped' do + p = Pool.new(1) + p.stop + job = proc {} + expect { p.schedule(&job) }.to_not raise_error + end + + it 'adds jobs that get run by the pool' do + p = Pool.new(1) + p.start + o, q = Object.new, Queue.new + job = proc { q.push(o) } + p.schedule(&job) + expect(q.pop).to be(o) + p.stop + end + + it 'it throws an error if all of the workers have tasks to do' do + p = Pool.new(5) + p.start + job = proc {} + 5.times do + expect(p.ready_for_work?).to be(true) + p.schedule(&job) + end + expect { p.schedule(&job) }.to raise_error + expect { p.schedule(&job) }.to raise_error + end + end + + describe '#stop' do + it 'works when there are no scheduled tasks' do + p = Pool.new(1) + expect { p.stop }.not_to raise_error + end + + it 'stops jobs when there are long running jobs' do + p = Pool.new(1) + p.start + o, q = Object.new, Queue.new + job = proc do + sleep(5) # long running + q.push(o) + end + p.schedule(&job) + sleep(1) # should ensure the long job gets scheduled + expect { p.stop }.not_to raise_error + end + end + + describe '#start' do + it 'runs jobs as they are scheduled' do + p = Pool.new(5) + o, q = Object.new, Queue.new + p.start + n = 5 # arbitrary + n.times do + p.schedule(o, &q.method(:push)) + expect(q.pop).to be(o) + end + p.stop + end + end +end |