get rid of servicename argument for server service definition.

pull/6801/head
Jan Tattermusch 9 years ago
parent 845a0567e3
commit 781720f82d
  1. 2
      src/csharp/Grpc.Core.Tests/MockServiceHelper.cs
  2. 2
      src/csharp/Grpc.Core.Tests/ServerTest.cs
  3. 4
      src/csharp/Grpc.Core/AsyncClientStreamingCall.cs
  4. 10
      src/csharp/Grpc.Core/ServerServiceDefinition.cs
  5. 2
      src/csharp/Grpc.IntegrationTesting/GenericService.cs

@ -102,7 +102,7 @@ namespace Grpc.Core.Tests
marshaller, marshaller,
marshaller); marshaller);
serviceDefinition = ServerServiceDefinition.CreateBuilder(ServiceName) serviceDefinition = ServerServiceDefinition.CreateBuilder()
.AddMethod(unaryMethod, (request, context) => unaryHandler(request, context)) .AddMethod(unaryMethod, (request, context) => unaryHandler(request, context))
.AddMethod(clientStreamingMethod, (requestStream, context) => clientStreamingHandler(requestStream, context)) .AddMethod(clientStreamingMethod, (requestStream, context) => clientStreamingHandler(requestStream, context))
.AddMethod(serverStreamingMethod, (request, responseStream, context) => serverStreamingHandler(request, responseStream, context)) .AddMethod(serverStreamingMethod, (request, responseStream, context) => serverStreamingHandler(request, responseStream, context))

@ -89,7 +89,7 @@ namespace Grpc.Core.Tests
}; };
server.Start(); server.Start();
Assert.Throws(typeof(InvalidOperationException), () => server.Ports.Add("localhost", 9999, ServerCredentials.Insecure)); Assert.Throws(typeof(InvalidOperationException), () => server.Ports.Add("localhost", 9999, ServerCredentials.Insecure));
Assert.Throws(typeof(InvalidOperationException), () => server.Services.Add(ServerServiceDefinition.CreateBuilder("serviceName").Build())); Assert.Throws(typeof(InvalidOperationException), () => server.Services.Add(ServerServiceDefinition.CreateBuilder().Build()));
server.ShutdownAsync().Wait(); server.ShutdownAsync().Wait();
} }

@ -127,6 +127,10 @@ namespace Grpc.Core
/// Otherwise, requests cancellation of the call which should terminate all pending async operations associated with the call. /// Otherwise, requests cancellation of the call which should terminate all pending async operations associated with the call.
/// As a result, all resources being used by the call should be released eventually. /// As a result, all resources being used by the call should be released eventually.
/// </summary> /// </summary>
/// <remarks>
/// Normally, there is no need for you to dispose the call unless you want to utilize the
/// "Cancel" semantics of invoking <c>Dispose</c>.
/// </remarks>
public void Dispose() public void Dispose()
{ {
disposeAction.Invoke(); disposeAction.Invoke();

@ -63,11 +63,10 @@ namespace Grpc.Core
/// <summary> /// <summary>
/// Creates a new builder object for <c>ServerServiceDefinition</c>. /// Creates a new builder object for <c>ServerServiceDefinition</c>.
/// </summary> /// </summary>
/// <param name="serviceName">The service name.</param>
/// <returns>The builder object.</returns> /// <returns>The builder object.</returns>
public static Builder CreateBuilder(string serviceName) public static Builder CreateBuilder()
{ {
return new Builder(serviceName); return new Builder();
} }
/// <summary> /// <summary>
@ -75,16 +74,13 @@ namespace Grpc.Core
/// </summary> /// </summary>
public class Builder public class Builder
{ {
readonly string serviceName;
readonly Dictionary<string, IServerCallHandler> callHandlers = new Dictionary<string, IServerCallHandler>(); readonly Dictionary<string, IServerCallHandler> callHandlers = new Dictionary<string, IServerCallHandler>();
/// <summary> /// <summary>
/// Creates a new instance of builder. /// Creates a new instance of builder.
/// </summary> /// </summary>
/// <param name="serviceName">The service name.</param> public Builder()
public Builder(string serviceName)
{ {
this.serviceName = serviceName;
} }
/// <summary> /// <summary>

@ -64,7 +64,7 @@ namespace Grpc.IntegrationTesting
public static ServerServiceDefinition BindHandler(DuplexStreamingServerMethod<byte[], byte[]> handler) public static ServerServiceDefinition BindHandler(DuplexStreamingServerMethod<byte[], byte[]> handler)
{ {
return ServerServiceDefinition.CreateBuilder(StreamingCallMethod.ServiceName) return ServerServiceDefinition.CreateBuilder()
.AddMethod(StreamingCallMethod, handler).Build(); .AddMethod(StreamingCallMethod, handler).Build();
} }
} }

Loading…
Cancel
Save