diff options
author | Craig Tiller <ctiller@google.com> | 2017-05-05 17:52:01 +0000 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-05-05 17:52:01 +0000 |
commit | a37ad7d1345e48dff8a60b92af384b99086f6ae6 (patch) | |
tree | c4bc7feef08271ec06e95511c51d5f3fcc1674c8 /examples/csharp/helloworld/Greeter | |
parent | 9247817082bc5d33ebe048a1aa0c5881fdb408ed (diff) | |
parent | 0994bbd0f7d8e97ca946ee97f24643d79e5d2c3e (diff) |
Merge branch 'trickle_stall' of github.com:ctiller/grpc into trickle_stall
Diffstat (limited to 'examples/csharp/helloworld/Greeter')
-rw-r--r-- | examples/csharp/helloworld/Greeter/Greeter.csproj | 29 | ||||
-rw-r--r-- | examples/csharp/helloworld/Greeter/Helloworld.cs | 37 | ||||
-rw-r--r-- | examples/csharp/helloworld/Greeter/HelloworldGrpc.cs | 73 | ||||
-rw-r--r-- | examples/csharp/helloworld/Greeter/packages.config | 12 |
4 files changed, 100 insertions, 51 deletions
diff --git a/examples/csharp/helloworld/Greeter/Greeter.csproj b/examples/csharp/helloworld/Greeter/Greeter.csproj index 036e6b59fb..8dcd2d9066 100644 --- a/examples/csharp/helloworld/Greeter/Greeter.csproj +++ b/examples/csharp/helloworld/Greeter/Greeter.csproj @@ -10,7 +10,8 @@ <RootNamespace>Greeter</RootNamespace> <AssemblyName>Greeter</AssemblyName> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> - <NuGetPackageImportStamp>2669b4f2</NuGetPackageImportStamp> + <NuGetPackageImportStamp> + </NuGetPackageImportStamp> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -31,18 +32,18 @@ <ConsolePause>false</ConsolePause> </PropertyGroup> <ItemGroup> - <Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll</HintPath> + <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> + <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath> + <Private>True</Private> </Reference> - <Reference Include="Grpc.Core, Version=1.0.1.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll</HintPath> + <Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL"> + <HintPath>..\packages\Grpc.Core.1.2.2\lib\net45\Grpc.Core.dll</HintPath> + <Private>True</Private> </Reference> <Reference Include="System" /> - <Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath> + <Reference Include="System.Interactive.Async, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL"> + <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath> + <Private>True</Private> </Reference> </ItemGroup> <ItemGroup> @@ -61,11 +62,11 @@ <None Include="packages.config" /> </ItemGroup> <ItemGroup /> - <Import Project="..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" /> + <Import Project="..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> - <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> + <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> </PropertyGroup> - <Error Condition="!Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets'))" /> + <Error Condition="!Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets'))" /> </Target> -</Project> +</Project>
\ No newline at end of file diff --git a/examples/csharp/helloworld/Greeter/Helloworld.cs b/examples/csharp/helloworld/Greeter/Helloworld.cs index 6477b4f35b..ecfc8e131c 100644 --- a/examples/csharp/helloworld/Greeter/Helloworld.cs +++ b/examples/csharp/helloworld/Greeter/Helloworld.cs @@ -10,7 +10,6 @@ using scg = global::System.Collections.Generic; namespace Helloworld { /// <summary>Holder for reflection information generated from helloworld.proto</summary> - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class HelloworldReflection { #region Descriptor @@ -41,31 +40,36 @@ namespace Helloworld { } #region Messages /// <summary> - /// The request message containing the user's name. + /// The request message containing the user's name. /// </summary> - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloRequest : pb::IMessage<HelloRequest> { private static readonly pb::MessageParser<HelloRequest> _parser = new pb::MessageParser<HelloRequest>(() => new HelloRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser<HelloRequest> Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest(HelloRequest other) : this() { name_ = other.name_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest Clone() { return new HelloRequest(this); } @@ -73,6 +77,7 @@ namespace Helloworld { /// <summary>Field number for the "name" field.</summary> public const int NameFieldNumber = 1; private string name_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -80,10 +85,12 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloRequest); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloRequest other) { if (ReferenceEquals(other, null)) { return false; @@ -95,16 +102,19 @@ namespace Helloworld { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Name.Length != 0) { output.WriteRawTag(10); @@ -112,6 +122,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -120,6 +131,7 @@ namespace Helloworld { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloRequest other) { if (other == null) { return; @@ -129,6 +141,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -147,31 +160,36 @@ namespace Helloworld { } /// <summary> - /// The response message containing the greetings + /// The response message containing the greetings /// </summary> - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloReply : pb::IMessage<HelloReply> { private static readonly pb::MessageParser<HelloReply> _parser = new pb::MessageParser<HelloReply>(() => new HelloReply()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser<HelloReply> Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply(HelloReply other) : this() { message_ = other.message_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply Clone() { return new HelloReply(this); } @@ -179,6 +197,7 @@ namespace Helloworld { /// <summary>Field number for the "message" field.</summary> public const int MessageFieldNumber = 1; private string message_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Message { get { return message_; } set { @@ -186,10 +205,12 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloReply); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloReply other) { if (ReferenceEquals(other, null)) { return false; @@ -201,16 +222,19 @@ namespace Helloworld { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Message.Length != 0) hash ^= Message.GetHashCode(); return hash; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override string ToString() { return pb::JsonFormatter.ToDiagnosticString(this); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { if (Message.Length != 0) { output.WriteRawTag(10); @@ -218,6 +242,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Message.Length != 0) { @@ -226,6 +251,7 @@ namespace Helloworld { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloReply other) { if (other == null) { return; @@ -235,6 +261,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { diff --git a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs index 041f5a78d7..b321ea9e68 100644 --- a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs +++ b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs @@ -35,21 +35,21 @@ using System; using System.Threading; using System.Threading.Tasks; -using Grpc.Core; +using grpc = global::Grpc.Core; namespace Helloworld { /// <summary> - /// The greeting service definition. + /// The greeting service definition. /// </summary> - public static class Greeter + public static partial class Greeter { static readonly string __ServiceName = "helloworld.Greeter"; - static readonly Marshaller<global::Helloworld.HelloRequest> __Marshaller_HelloRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloRequest.Parser.ParseFrom); - static readonly Marshaller<global::Helloworld.HelloReply> __Marshaller_HelloReply = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloReply.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Helloworld.HelloRequest> __Marshaller_HelloRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloRequest.Parser.ParseFrom); + static readonly grpc::Marshaller<global::Helloworld.HelloReply> __Marshaller_HelloReply = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloReply.Parser.ParseFrom); - static readonly Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply> __Method_SayHello = new Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply>( - MethodType.Unary, + static readonly grpc::Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply> __Method_SayHello = new grpc::Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply>( + grpc::MethodType.Unary, __ServiceName, "SayHello", __Marshaller_HelloRequest, @@ -62,29 +62,32 @@ namespace Helloworld { } /// <summary>Base class for server-side implementations of Greeter</summary> - public abstract class GreeterBase + public abstract partial class GreeterBase { /// <summary> - /// Sends a greeting + /// Sends a greeting /// </summary> - public virtual global::System.Threading.Tasks.Task<global::Helloworld.HelloReply> SayHello(global::Helloworld.HelloRequest request, ServerCallContext context) + /// <param name="request">The request received from the client.</param> + /// <param name="context">The context of the server-side call handler being invoked.</param> + /// <returns>The response to send back to the client (wrapped by a task).</returns> + public virtual global::System.Threading.Tasks.Task<global::Helloworld.HelloReply> SayHello(global::Helloworld.HelloRequest request, grpc::ServerCallContext context) { - throw new RpcException(new Status(StatusCode.Unimplemented, "")); + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } } /// <summary>Client for Greeter</summary> - public class GreeterClient : ClientBase<GreeterClient> + public partial class GreeterClient : grpc::ClientBase<GreeterClient> { /// <summary>Creates a new client for Greeter</summary> /// <param name="channel">The channel to use to make remote calls.</param> - public GreeterClient(Channel channel) : base(channel) + public GreeterClient(grpc::Channel channel) : base(channel) { } /// <summary>Creates a new client for Greeter that uses a custom <c>CallInvoker</c>.</summary> /// <param name="callInvoker">The callInvoker to use to make remote calls.</param> - public GreeterClient(CallInvoker callInvoker) : base(callInvoker) + public GreeterClient(grpc::CallInvoker callInvoker) : base(callInvoker) { } /// <summary>Protected parameterless constructor to allow creation of test doubles.</summary> @@ -98,33 +101,50 @@ namespace Helloworld { } /// <summary> - /// Sends a greeting + /// Sends a greeting /// </summary> - public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + /// <param name="request">The request to send to the server.</param> + /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param> + /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param> + /// <param name="cancellationToken">An optional token for canceling the call.</param> + /// <returns>The response received from the server.</returns> + public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return SayHello(request, new CallOptions(headers, deadline, cancellationToken)); + return SayHello(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// <summary> - /// Sends a greeting + /// Sends a greeting /// </summary> - public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, CallOptions options) + /// <param name="request">The request to send to the server.</param> + /// <param name="options">The options for the call.</param> + /// <returns>The response received from the server.</returns> + public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, grpc::CallOptions options) { return CallInvoker.BlockingUnaryCall(__Method_SayHello, null, options, request); } /// <summary> - /// Sends a greeting + /// Sends a greeting /// </summary> - public virtual AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + /// <param name="request">The request to send to the server.</param> + /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param> + /// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param> + /// <param name="cancellationToken">An optional token for canceling the call.</param> + /// <returns>The call object.</returns> + public virtual grpc::AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - return SayHelloAsync(request, new CallOptions(headers, deadline, cancellationToken)); + return SayHelloAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); } /// <summary> - /// Sends a greeting + /// Sends a greeting /// </summary> - public virtual AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, CallOptions options) + /// <param name="request">The request to send to the server.</param> + /// <param name="options">The options for the call.</param> + /// <returns>The call object.</returns> + public virtual grpc::AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, grpc::CallOptions options) { return CallInvoker.AsyncUnaryCall(__Method_SayHello, null, options, request); } + /// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary> protected override GreeterClient NewInstance(ClientBaseConfiguration configuration) { return new GreeterClient(configuration); @@ -132,9 +152,10 @@ namespace Helloworld { } /// <summary>Creates service definition that can be registered with a server</summary> - public static ServerServiceDefinition BindService(GreeterBase serviceImpl) + /// <param name="serviceImpl">An object implementing the server-side handling logic.</param> + public static grpc::ServerServiceDefinition BindService(GreeterBase serviceImpl) { - return ServerServiceDefinition.CreateBuilder() + return grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_SayHello, serviceImpl.SayHello).Build(); } diff --git a/examples/csharp/helloworld/Greeter/packages.config b/examples/csharp/helloworld/Greeter/packages.config index 2bb3a182a6..ec83cd8300 100644 --- a/examples/csharp/helloworld/Greeter/packages.config +++ b/examples/csharp/helloworld/Greeter/packages.config @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <packages> - <package id="Google.Protobuf" version="3.0.0" targetFramework="net45" /> - <package id="Grpc" version="1.0.1" targetFramework="net45" /> - <package id="Grpc.Core" version="1.0.1" targetFramework="net45" /> - <package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" /> - <package id="Grpc.Tools" version="1.0.1" targetFramework="net45" /> -</packages> + <package id="Google.Protobuf" version="3.2.0" targetFramework="net45" /> + <package id="Grpc" version="1.2.2" targetFramework="net45" /> + <package id="Grpc.Core" version="1.2.2" targetFramework="net45" /> + <package id="Grpc.Tools" version="1.2.2" targetFramework="net45" /> + <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" /> +</packages>
\ No newline at end of file |