diff options
Diffstat (limited to 'examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs')
-rw-r--r-- | examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs | 368 |
1 files changed, 325 insertions, 43 deletions
diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs index 66d1c07978..a59906d9c1 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs +++ b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs @@ -1,5 +1,35 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: route_guide.proto +// Original file comments: +// 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. +// #region Designer generated code using System; @@ -8,6 +38,9 @@ using System.Threading.Tasks; using Grpc.Core; namespace Routeguide { + /// <summary> + /// Interface exported by the server. + /// </summary> public static class RouteGuide { static readonly string __ServiceName = "routeguide.RouteGuide"; @@ -46,96 +79,339 @@ namespace Routeguide { __Marshaller_RouteNote, __Marshaller_RouteNote); - // service descriptor + /// <summary>Service descriptor</summary> public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.Services[0]; } } - // client interface + /// <summary>Client for RouteGuide</summary> + [System.Obsolete("Client side interfaced will be removed in the next release. Use client class directly.")] public interface IRouteGuideClient { + /// <summary> + /// A simple RPC. + /// + /// Obtains the feature at a given position. + /// + /// A feature with an empty name is returned if there's no feature at the given + /// position. + /// </summary> global::Routeguide.Feature GetFeature(global::Routeguide.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// A simple RPC. + /// + /// Obtains the feature at a given position. + /// + /// A feature with an empty name is returned if there's no feature at the given + /// position. + /// </summary> global::Routeguide.Feature GetFeature(global::Routeguide.Point request, CallOptions options); + /// <summary> + /// A simple RPC. + /// + /// Obtains the feature at a given position. + /// + /// A feature with an empty name is returned if there's no feature at the given + /// position. + /// </summary> AsyncUnaryCall<global::Routeguide.Feature> GetFeatureAsync(global::Routeguide.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// A simple RPC. + /// + /// Obtains the feature at a given position. + /// + /// A feature with an empty name is returned if there's no feature at the given + /// position. + /// </summary> AsyncUnaryCall<global::Routeguide.Feature> GetFeatureAsync(global::Routeguide.Point request, CallOptions options); + /// <summary> + /// A server-to-client streaming RPC. + /// + /// Obtains the Features available within the given Rectangle. Results are + /// streamed rather than returned at once (e.g. in a response message with a + /// repeated field), as the rectangle may cover a large area and contain a + /// huge number of features. + /// </summary> AsyncServerStreamingCall<global::Routeguide.Feature> ListFeatures(global::Routeguide.Rectangle request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// A server-to-client streaming RPC. + /// + /// Obtains the Features available within the given Rectangle. Results are + /// streamed rather than returned at once (e.g. in a response message with a + /// repeated field), as the rectangle may cover a large area and contain a + /// huge number of features. + /// </summary> AsyncServerStreamingCall<global::Routeguide.Feature> ListFeatures(global::Routeguide.Rectangle request, CallOptions options); + /// <summary> + /// A client-to-server streaming RPC. + /// + /// Accepts a stream of Points on a route being traversed, returning a + /// RouteSummary when traversal is completed. + /// </summary> AsyncClientStreamingCall<global::Routeguide.Point, global::Routeguide.RouteSummary> RecordRoute(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// A client-to-server streaming RPC. + /// + /// Accepts a stream of Points on a route being traversed, returning a + /// RouteSummary when traversal is completed. + /// </summary> AsyncClientStreamingCall<global::Routeguide.Point, global::Routeguide.RouteSummary> RecordRoute(CallOptions options); + /// <summary> + /// A Bidirectional streaming RPC. + /// + /// Accepts a stream of RouteNotes sent while a route is being traversed, + /// while receiving other RouteNotes (e.g. from other users). + /// </summary> AsyncDuplexStreamingCall<global::Routeguide.RouteNote, global::Routeguide.RouteNote> RouteChat(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); + /// <summary> + /// A Bidirectional streaming RPC. + /// + /// Accepts a stream of RouteNotes sent while a route is being traversed, + /// while receiving other RouteNotes (e.g. from other users). + /// </summary> AsyncDuplexStreamingCall<global::Routeguide.RouteNote, global::Routeguide.RouteNote> RouteChat(CallOptions options); } - // server-side interface + /// <summary>Interface of server-side implementations of RouteGuide</summary> + [System.Obsolete("Service implementations should inherit from the generated abstract base class instead.")] public interface IRouteGuide { - Task<global::Routeguide.Feature> GetFeature(global::Routeguide.Point request, ServerCallContext context); - Task ListFeatures(global::Routeguide.Rectangle request, IServerStreamWriter<global::Routeguide.Feature> responseStream, ServerCallContext context); - Task<global::Routeguide.RouteSummary> RecordRoute(IAsyncStreamReader<global::Routeguide.Point> requestStream, ServerCallContext context); - Task RouteChat(IAsyncStreamReader<global::Routeguide.RouteNote> requestStream, IServerStreamWriter<global::Routeguide.RouteNote> responseStream, ServerCallContext context); + /// <summary> + /// A simple RPC. + /// + /// Obtains the feature at a given position. + /// + /// A feature with an empty name is returned if there's no feature at the given + /// position. + /// </summary> + global::System.Threading.Tasks.Task<global::Routeguide.Feature> GetFeature(global::Routeguide.Point request, ServerCallContext context); + /// <summary> + /// A server-to-client streaming RPC. + /// + /// Obtains the Features available within the given Rectangle. Results are + /// streamed rather than returned at once (e.g. in a response message with a + /// repeated field), as the rectangle may cover a large area and contain a + /// huge number of features. + /// </summary> + global::System.Threading.Tasks.Task ListFeatures(global::Routeguide.Rectangle request, IServerStreamWriter<global::Routeguide.Feature> responseStream, ServerCallContext context); + /// <summary> + /// A client-to-server streaming RPC. + /// + /// Accepts a stream of Points on a route being traversed, returning a + /// RouteSummary when traversal is completed. + /// </summary> + global::System.Threading.Tasks.Task<global::Routeguide.RouteSummary> RecordRoute(IAsyncStreamReader<global::Routeguide.Point> requestStream, ServerCallContext context); + /// <summary> + /// A Bidirectional streaming RPC. + /// + /// Accepts a stream of RouteNotes sent while a route is being traversed, + /// while receiving other RouteNotes (e.g. from other users). + /// </summary> + global::System.Threading.Tasks.Task RouteChat(IAsyncStreamReader<global::Routeguide.RouteNote> requestStream, IServerStreamWriter<global::Routeguide.RouteNote> responseStream, ServerCallContext context); } - // client stub - public class RouteGuideClient : ClientBase, IRouteGuideClient + /// <summary>Base class for server-side implementations of RouteGuide</summary> + public abstract class RouteGuideBase + { + /// <summary> + /// A simple RPC. + /// + /// Obtains the feature at a given position. + /// + /// A feature with an empty name is returned if there's no feature at the given + /// position. + /// </summary> + public virtual global::System.Threading.Tasks.Task<global::Routeguide.Feature> GetFeature(global::Routeguide.Point request, ServerCallContext context) + { + throw new RpcException(new Status(StatusCode.Unimplemented, "")); + } + + /// <summary> + /// A server-to-client streaming RPC. + /// + /// Obtains the Features available within the given Rectangle. Results are + /// streamed rather than returned at once (e.g. in a response message with a + /// repeated field), as the rectangle may cover a large area and contain a + /// huge number of features. + /// </summary> + public virtual global::System.Threading.Tasks.Task ListFeatures(global::Routeguide.Rectangle request, IServerStreamWriter<global::Routeguide.Feature> responseStream, ServerCallContext context) + { + throw new RpcException(new Status(StatusCode.Unimplemented, "")); + } + + /// <summary> + /// A client-to-server streaming RPC. + /// + /// Accepts a stream of Points on a route being traversed, returning a + /// RouteSummary when traversal is completed. + /// </summary> + public virtual global::System.Threading.Tasks.Task<global::Routeguide.RouteSummary> RecordRoute(IAsyncStreamReader<global::Routeguide.Point> requestStream, ServerCallContext context) + { + throw new RpcException(new Status(StatusCode.Unimplemented, "")); + } + + /// <summary> + /// A Bidirectional streaming RPC. + /// + /// Accepts a stream of RouteNotes sent while a route is being traversed, + /// while receiving other RouteNotes (e.g. from other users). + /// </summary> + public virtual global::System.Threading.Tasks.Task RouteChat(IAsyncStreamReader<global::Routeguide.RouteNote> requestStream, IServerStreamWriter<global::Routeguide.RouteNote> responseStream, ServerCallContext context) + { + throw new RpcException(new Status(StatusCode.Unimplemented, "")); + } + + } + + /// <summary>Client for RouteGuide</summary> + #pragma warning disable 0618 + public class RouteGuideClient : ClientBase<RouteGuideClient>, IRouteGuideClient + #pragma warning restore 0618 { public RouteGuideClient(Channel channel) : base(channel) { } - public global::Routeguide.Feature GetFeature(global::Routeguide.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + public RouteGuideClient(CallInvoker callInvoker) : base(callInvoker) + { + } + ///<summary>Protected parameterless constructor to allow creation of test doubles.</summary> + protected RouteGuideClient() : base() + { + } + ///<summary>Protected constructor to allow creation of configured clients.</summary> + protected RouteGuideClient(ClientBaseConfiguration configuration) : base(configuration) { - var call = CreateCall(__Method_GetFeature, new CallOptions(headers, deadline, cancellationToken)); - return Calls.BlockingUnaryCall(call, request); } - public global::Routeguide.Feature GetFeature(global::Routeguide.Point request, CallOptions options) + + /// <summary> + /// A simple RPC. + /// + /// Obtains the feature at a given position. + /// + /// A feature with an empty name is returned if there's no feature at the given + /// position. + /// </summary> + public virtual global::Routeguide.Feature GetFeature(global::Routeguide.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - var call = CreateCall(__Method_GetFeature, options); - return Calls.BlockingUnaryCall(call, request); + return GetFeature(request, new CallOptions(headers, deadline, cancellationToken)); } - public AsyncUnaryCall<global::Routeguide.Feature> GetFeatureAsync(global::Routeguide.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + /// <summary> + /// A simple RPC. + /// + /// Obtains the feature at a given position. + /// + /// A feature with an empty name is returned if there's no feature at the given + /// position. + /// </summary> + public virtual global::Routeguide.Feature GetFeature(global::Routeguide.Point request, CallOptions options) { - var call = CreateCall(__Method_GetFeature, new CallOptions(headers, deadline, cancellationToken)); - return Calls.AsyncUnaryCall(call, request); + return CallInvoker.BlockingUnaryCall(__Method_GetFeature, null, options, request); } - public AsyncUnaryCall<global::Routeguide.Feature> GetFeatureAsync(global::Routeguide.Point request, CallOptions options) + /// <summary> + /// A simple RPC. + /// + /// Obtains the feature at a given position. + /// + /// A feature with an empty name is returned if there's no feature at the given + /// position. + /// </summary> + public virtual AsyncUnaryCall<global::Routeguide.Feature> GetFeatureAsync(global::Routeguide.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - var call = CreateCall(__Method_GetFeature, options); - return Calls.AsyncUnaryCall(call, request); + return GetFeatureAsync(request, new CallOptions(headers, deadline, cancellationToken)); } - public AsyncServerStreamingCall<global::Routeguide.Feature> ListFeatures(global::Routeguide.Rectangle request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + /// <summary> + /// A simple RPC. + /// + /// Obtains the feature at a given position. + /// + /// A feature with an empty name is returned if there's no feature at the given + /// position. + /// </summary> + public virtual AsyncUnaryCall<global::Routeguide.Feature> GetFeatureAsync(global::Routeguide.Point request, CallOptions options) { - var call = CreateCall(__Method_ListFeatures, new CallOptions(headers, deadline, cancellationToken)); - return Calls.AsyncServerStreamingCall(call, request); + return CallInvoker.AsyncUnaryCall(__Method_GetFeature, null, options, request); } - public AsyncServerStreamingCall<global::Routeguide.Feature> ListFeatures(global::Routeguide.Rectangle request, CallOptions options) + /// <summary> + /// A server-to-client streaming RPC. + /// + /// Obtains the Features available within the given Rectangle. Results are + /// streamed rather than returned at once (e.g. in a response message with a + /// repeated field), as the rectangle may cover a large area and contain a + /// huge number of features. + /// </summary> + public virtual AsyncServerStreamingCall<global::Routeguide.Feature> ListFeatures(global::Routeguide.Rectangle request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - var call = CreateCall(__Method_ListFeatures, options); - return Calls.AsyncServerStreamingCall(call, request); + return ListFeatures(request, new CallOptions(headers, deadline, cancellationToken)); } - public AsyncClientStreamingCall<global::Routeguide.Point, global::Routeguide.RouteSummary> RecordRoute(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + /// <summary> + /// A server-to-client streaming RPC. + /// + /// Obtains the Features available within the given Rectangle. Results are + /// streamed rather than returned at once (e.g. in a response message with a + /// repeated field), as the rectangle may cover a large area and contain a + /// huge number of features. + /// </summary> + public virtual AsyncServerStreamingCall<global::Routeguide.Feature> ListFeatures(global::Routeguide.Rectangle request, CallOptions options) { - var call = CreateCall(__Method_RecordRoute, new CallOptions(headers, deadline, cancellationToken)); - return Calls.AsyncClientStreamingCall(call); + return CallInvoker.AsyncServerStreamingCall(__Method_ListFeatures, null, options, request); } - public AsyncClientStreamingCall<global::Routeguide.Point, global::Routeguide.RouteSummary> RecordRoute(CallOptions options) + /// <summary> + /// A client-to-server streaming RPC. + /// + /// Accepts a stream of Points on a route being traversed, returning a + /// RouteSummary when traversal is completed. + /// </summary> + public virtual AsyncClientStreamingCall<global::Routeguide.Point, global::Routeguide.RouteSummary> RecordRoute(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - var call = CreateCall(__Method_RecordRoute, options); - return Calls.AsyncClientStreamingCall(call); + return RecordRoute(new CallOptions(headers, deadline, cancellationToken)); } - public AsyncDuplexStreamingCall<global::Routeguide.RouteNote, global::Routeguide.RouteNote> RouteChat(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + /// <summary> + /// A client-to-server streaming RPC. + /// + /// Accepts a stream of Points on a route being traversed, returning a + /// RouteSummary when traversal is completed. + /// </summary> + public virtual AsyncClientStreamingCall<global::Routeguide.Point, global::Routeguide.RouteSummary> RecordRoute(CallOptions options) { - var call = CreateCall(__Method_RouteChat, new CallOptions(headers, deadline, cancellationToken)); - return Calls.AsyncDuplexStreamingCall(call); + return CallInvoker.AsyncClientStreamingCall(__Method_RecordRoute, null, options); } - public AsyncDuplexStreamingCall<global::Routeguide.RouteNote, global::Routeguide.RouteNote> RouteChat(CallOptions options) + /// <summary> + /// A Bidirectional streaming RPC. + /// + /// Accepts a stream of RouteNotes sent while a route is being traversed, + /// while receiving other RouteNotes (e.g. from other users). + /// </summary> + public virtual AsyncDuplexStreamingCall<global::Routeguide.RouteNote, global::Routeguide.RouteNote> RouteChat(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) { - var call = CreateCall(__Method_RouteChat, options); - return Calls.AsyncDuplexStreamingCall(call); + return RouteChat(new CallOptions(headers, deadline, cancellationToken)); } + /// <summary> + /// A Bidirectional streaming RPC. + /// + /// Accepts a stream of RouteNotes sent while a route is being traversed, + /// while receiving other RouteNotes (e.g. from other users). + /// </summary> + public virtual AsyncDuplexStreamingCall<global::Routeguide.RouteNote, global::Routeguide.RouteNote> RouteChat(CallOptions options) + { + return CallInvoker.AsyncDuplexStreamingCall(__Method_RouteChat, null, options); + } + protected override RouteGuideClient NewInstance(ClientBaseConfiguration configuration) + { + return new RouteGuideClient(configuration); + } + } + + /// <summary>Creates a new client for RouteGuide</summary> + public static RouteGuideClient NewClient(Channel channel) + { + return new RouteGuideClient(channel); } - // creates service definition that can be registered with a server + /// <summary>Creates service definition that can be registered with a server</summary> + #pragma warning disable 0618 public static ServerServiceDefinition BindService(IRouteGuide serviceImpl) + #pragma warning restore 0618 { return ServerServiceDefinition.CreateBuilder(__ServiceName) .AddMethod(__Method_GetFeature, serviceImpl.GetFeature) @@ -144,10 +420,16 @@ namespace Routeguide { .AddMethod(__Method_RouteChat, serviceImpl.RouteChat).Build(); } - // creates a new client - public static RouteGuideClient NewClient(Channel channel) + /// <summary>Creates service definition that can be registered with a server</summary> + #pragma warning disable 0618 + public static ServerServiceDefinition BindService(RouteGuideBase serviceImpl) + #pragma warning restore 0618 { - return new RouteGuideClient(channel); + return ServerServiceDefinition.CreateBuilder(__ServiceName) + .AddMethod(__Method_GetFeature, serviceImpl.GetFeature) + .AddMethod(__Method_ListFeatures, serviceImpl.ListFeatures) + .AddMethod(__Method_RecordRoute, serviceImpl.RecordRoute) + .AddMethod(__Method_RouteChat, serviceImpl.RouteChat).Build(); } } |