Merge branch 'master' into grpc_namespace_server

pull/18458/head
Karthik Ravi Shankar 6 years ago
commit 17e78733b0
  1. 4
      src/compiler/csharp_generator.cc
  2. 53
      src/csharp/Grpc.Core.Api/BindServiceMethodAttribute.cs
  3. 1
      src/csharp/Grpc.Examples/MathGrpc.cs
  4. 1
      src/csharp/Grpc.HealthCheck/HealthGrpc.cs
  5. 1
      src/csharp/Grpc.IntegrationTesting/BenchmarkServiceGrpc.cs
  6. 1
      src/csharp/Grpc.IntegrationTesting/EmptyServiceGrpc.cs
  7. 1
      src/csharp/Grpc.IntegrationTesting/MetricsGrpc.cs
  8. 1
      src/csharp/Grpc.IntegrationTesting/ReportQpsScenarioServiceGrpc.cs
  9. 3
      src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
  10. 1
      src/csharp/Grpc.IntegrationTesting/WorkerServiceGrpc.cs
  11. 1
      src/csharp/Grpc.Reflection/ReflectionGrpc.cs
  12. 13
      test/cpp/end2end/xds_end2end_test.cc

@ -382,6 +382,10 @@ void GenerateServerClass(Printer* out, const ServiceDescriptor* service) {
"/// <summary>Base class for server-side implementations of "
"$servicename$</summary>\n",
"servicename", GetServiceClassName(service));
out->Print(
"[grpc::BindServiceMethod(typeof($classname$), "
"\"BindService\")]\n",
"classname", GetServiceClassName(service));
out->Print("public abstract partial class $name$\n", "name",
GetServerClassName(service));
out->Print("{\n");

@ -0,0 +1,53 @@
#region Copyright notice and license
// Copyright 2019 The gRPC Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion
using System;
namespace Grpc.Core
{
/// <summary>
/// Specifies the location of the service bind method for a gRPC service.
/// The bind method is typically generated code and is used to register a service's
/// methods with the server on startup.
///
/// The bind method signature takes a <see cref="ServiceBinderBase"/> and an optional
/// instance of the service base class, e.g. <c>static void BindService(ServiceBinderBase, GreeterService)</c>.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class BindServiceMethodAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="BindServiceMethodAttribute"/> class.
/// </summary>
/// <param name="bindType">The type the service bind method is defined on.</param>
/// <param name="bindMethodName">The name of the service bind method.</param>
public BindServiceMethodAttribute(Type bindType, string bindMethodName)
{
BindType = bindType;
BindMethodName = bindMethodName;
}
/// <summary>
/// Gets the type the service bind method is defined on.
/// </summary>
public Type BindType { get; }
/// <summary>
/// Gets the name of the service bind method.
/// </summary>
public string BindMethodName { get; }
}
}

@ -67,6 +67,7 @@ namespace Math {
}
/// <summary>Base class for server-side implementations of Math</summary>
[grpc::BindServiceMethod(typeof(Math), "BindService")]
public abstract partial class MathBase
{
/// <summary>

@ -54,6 +54,7 @@ namespace Grpc.Health.V1 {
}
/// <summary>Base class for server-side implementations of Health</summary>
[grpc::BindServiceMethod(typeof(Health), "BindService")]
public abstract partial class HealthBase
{
/// <summary>

@ -74,6 +74,7 @@ namespace Grpc.Testing {
}
/// <summary>Base class for server-side implementations of BenchmarkService</summary>
[grpc::BindServiceMethod(typeof(BenchmarkService), "BindService")]
public abstract partial class BenchmarkServiceBase
{
/// <summary>

@ -39,6 +39,7 @@ namespace Grpc.Testing {
}
/// <summary>Base class for server-side implementations of EmptyService</summary>
[grpc::BindServiceMethod(typeof(EmptyService), "BindService")]
public abstract partial class EmptyServiceBase
{
}

@ -58,6 +58,7 @@ namespace Grpc.Testing {
}
/// <summary>Base class for server-side implementations of MetricsService</summary>
[grpc::BindServiceMethod(typeof(MetricsService), "BindService")]
public abstract partial class MetricsServiceBase
{
/// <summary>

@ -46,6 +46,7 @@ namespace Grpc.Testing {
}
/// <summary>Base class for server-side implementations of ReportQpsScenarioService</summary>
[grpc::BindServiceMethod(typeof(ReportQpsScenarioService), "BindService")]
public abstract partial class ReportQpsScenarioServiceBase
{
/// <summary>

@ -105,6 +105,7 @@ namespace Grpc.Testing {
}
/// <summary>Base class for server-side implementations of TestService</summary>
[grpc::BindServiceMethod(typeof(TestService), "BindService")]
public abstract partial class TestServiceBase
{
/// <summary>
@ -580,6 +581,7 @@ namespace Grpc.Testing {
}
/// <summary>Base class for server-side implementations of UnimplementedService</summary>
[grpc::BindServiceMethod(typeof(UnimplementedService), "BindService")]
public abstract partial class UnimplementedServiceBase
{
/// <summary>
@ -719,6 +721,7 @@ namespace Grpc.Testing {
}
/// <summary>Base class for server-side implementations of ReconnectService</summary>
[grpc::BindServiceMethod(typeof(ReconnectService), "BindService")]
public abstract partial class ReconnectServiceBase
{
public virtual global::System.Threading.Tasks.Task<global::Grpc.Testing.Empty> Start(global::Grpc.Testing.ReconnectParams request, grpc::ServerCallContext context)

@ -72,6 +72,7 @@ namespace Grpc.Testing {
}
/// <summary>Base class for server-side implementations of WorkerService</summary>
[grpc::BindServiceMethod(typeof(WorkerService), "BindService")]
public abstract partial class WorkerServiceBase
{
/// <summary>

@ -46,6 +46,7 @@ namespace Grpc.Reflection.V1Alpha {
}
/// <summary>Base class for server-side implementations of ServerReflection</summary>
[grpc::BindServiceMethod(typeof(ServerReflection), "BindService")]
public abstract partial class ServerReflectionBase
{
/// <summary>

@ -860,25 +860,16 @@ TEST_F(SingleBalancerTest, AllServersUnreachableFailFast) {
TEST_F(SingleBalancerTest, BackendsRestart) {
SetNextResolution({}, kDefaultServiceConfig_.c_str());
SetNextResolutionForLbChannelAllBalancers();
const size_t kNumRpcsPerAddress = 100;
ScheduleResponseForBalancer(
0, BalancerServiceImpl::BuildResponseForBackends(GetBackendPorts(), {}),
0);
// Make sure that trying to connect works without a call.
channel_->GetState(true /* try_to_connect */);
// Send kNumRpcsPerAddress RPCs per server.
CheckRpcSendOk(kNumRpcsPerAddress * num_backends_);
balancers_[0]->service_.NotifyDoneWithServerlists();
// The balancer got a single request.
EXPECT_EQ(1U, balancers_[0]->service_.request_count());
// and sent a single response.
EXPECT_EQ(1U, balancers_[0]->service_.response_count());
WaitForAllBackends();
// Stop backends. RPCs should fail.
ShutdownAllBackends();
CheckRpcSendFailure();
// Restart all backends. RPCs should start succeeding again.
StartAllBackends();
CheckRpcSendOk(1 /* times */, 1000 /* timeout_ms */,
CheckRpcSendOk(1 /* times */, 2000 /* timeout_ms */,
true /* wait_for_ready */);
}

Loading…
Cancel
Save