From cc058e1118d35c8b2fd2298841c40f9303e6ce09 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 29 Apr 2015 08:55:07 +0100 Subject: Remove RPC support. It is expected that third parties will generate service/RPC code themselves - see gRPC as an example. --- csharp/src/ProtocolBuffers/IRpcChannel.cs | 63 ----------- csharp/src/ProtocolBuffers/IRpcController.cs | 125 --------------------- csharp/src/ProtocolBuffers/IRpcDispatch.cs | 78 ------------- csharp/src/ProtocolBuffers/IService.cs | 102 ----------------- csharp/src/ProtocolBuffers/ProtocolBuffers.csproj | 5 - .../src/ProtocolBuffers/ProtocolBuffersLite.csproj | 1 - csharp/src/ProtocolBuffers/RpcUtil.cs | 79 ------------- 7 files changed, 453 deletions(-) delete mode 100644 csharp/src/ProtocolBuffers/IRpcChannel.cs delete mode 100644 csharp/src/ProtocolBuffers/IRpcController.cs delete mode 100644 csharp/src/ProtocolBuffers/IRpcDispatch.cs delete mode 100644 csharp/src/ProtocolBuffers/IService.cs delete mode 100644 csharp/src/ProtocolBuffers/RpcUtil.cs (limited to 'csharp/src/ProtocolBuffers') diff --git a/csharp/src/ProtocolBuffers/IRpcChannel.cs b/csharp/src/ProtocolBuffers/IRpcChannel.cs deleted file mode 100644 index 4ca24ea7..00000000 --- a/csharp/src/ProtocolBuffers/IRpcChannel.cs +++ /dev/null @@ -1,63 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ -// -// 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. - -#endregion - -using System; -using Google.ProtocolBuffers.Descriptors; - -namespace Google.ProtocolBuffers -{ - /// - /// Interface for an RPC channel. A channel represents a communication line to - /// a service (IService implementation) which can be used to call that service's - /// methods. The service may be running on another machine. Normally, you should - /// not call an IRpcChannel directly, but instead construct a stub wrapping it. - /// Generated service classes contain a CreateStub method for precisely this purpose. - /// - public interface IRpcChannel - { - /// - /// Calls the given method of the remote service. This method is similar - /// to with one important difference: the - /// caller decides the types of the IMessage objects, not the implementation. - /// The request may be of any type as long as request.Descriptor == method.InputType. - /// The response passed to the callback will be of the same type as - /// (which must be such that - /// responsePrototype.Descriptor == method.OutputType). - /// - void CallMethod(MethodDescriptor method, IRpcController controller, - IMessage request, IMessage responsePrototype, Action done); - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/IRpcController.cs b/csharp/src/ProtocolBuffers/IRpcController.cs deleted file mode 100644 index b155bec5..00000000 --- a/csharp/src/ProtocolBuffers/IRpcController.cs +++ /dev/null @@ -1,125 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ -// -// 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. - -#endregion - -using System; - -namespace Google.ProtocolBuffers -{ - /// - /// Mediates a single method call. The primary purpose of the controller - /// is to provide a way to manipulate settings specific to the - /// RPC implementation and to find out about RPC-level errors. - /// - /// The methods provided by this interface are intended to be a "least - /// common denominator" set of features which we expect all implementations to - /// support. Specific implementations may provide more advanced features, - /// (e.g. deadline propagation). - /// - public interface IRpcController - { - #region Client side calls - - // These calls may be made from the client side only. Their results - // are undefined on the server side (may throw exceptions). - - /// - /// Resets the controller to its initial state so that it may be reused in - /// a new call. This can be called from the client side only. It must not - /// be called while an RPC is in progress. - /// - void Reset(); - - /// - /// After a call has finished, returns true if the call failed. The possible - /// reasons for failure depend on the RPC implementation. Failed must - /// only be called on the client side, and must not be called before a call has - /// finished. - /// - bool Failed { get; } - - /// - /// If Failed is true, ErrorText returns a human-readable description of the error. - /// - string ErrorText { get; } - - /// - /// Advises the RPC system that the caller desires that the RPC call be - /// canceled. The RPC system may cancel it immediately, may wait awhile and - /// then cancel it, or may not even cancel the call at all. If the call is - /// canceled, the "done" callback will still be called and the RpcController - /// will indicate that the call failed at that time. - /// - void StartCancel(); - - #endregion - - #region Server side calls - - // These calls may be made from the server side only. Their results - // are undefined on the client side (may throw exceptions). - - /// - /// Causes Failed to return true on the client side. - /// will be incorporated into the message returned by ErrorText. - /// If you find you need to return machine-readable information about - /// failures, you should incorporate it into your response protocol buffer - /// and should *not* call SetFailed. - /// - void SetFailed(string reason); - - /// - /// If true, indicates that the client canceled the RPC, so the server may as - /// well give up on replying to it. This method must be called on the server - /// side only. The server should still call the final "done" callback. - /// - bool IsCanceled(); - - /// - /// Requests that the given callback be called when the RPC is canceled. - /// The parameter passed to the callback will always be null. The callback will - /// be called exactly once. If the RPC completes without being canceled, the - /// callback will be called after completion. If the RPC has already been canceled - /// when NotifyOnCancel is called, the callback will be called immediately. - /// - /// NotifyOnCancel must be called no more than once per request. It must be - /// called on the server side only. - /// - /// - void NotifyOnCancel(Action callback); - - #endregion - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/IRpcDispatch.cs b/csharp/src/ProtocolBuffers/IRpcDispatch.cs deleted file mode 100644 index 524838e4..00000000 --- a/csharp/src/ProtocolBuffers/IRpcDispatch.cs +++ /dev/null @@ -1,78 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ -// -// 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. - -#endregion - -using System; - -namespace Google.ProtocolBuffers -{ - /// - /// Provides an entry-point for transport listeners to call a specified method on a service - /// - public interface IRpcServerStub : IDisposable - { - /// - /// Calls the method identified by methodName and returns the message - /// - /// The method name on the service descriptor (case-sensitive) - /// The ICodedInputStream to deserialize the call parameter from - /// The extension registry to use when deserializing the call parameter - /// The message that was returned from the service's method - IMessageLite CallMethod(string methodName, ICodedInputStream input, ExtensionRegistry registry); - } - - /// - /// Used to forward an invocation of a service method to a transport sender implementation - /// - public interface IRpcDispatch - { - /// - /// Calls the service member on the endpoint connected. This is generally done by serializing - /// the message, sending the bytes over a transport, and then deserializing the call parameter - /// to invoke the service's actual implementation via IRpcServerStub. Once the call has - /// completed the result message is serialized and returned to the originating endpoint. - /// - /// The type of the response message - /// The type of of the response builder - /// The name of the method on the service - /// The message instance provided to the service call - /// The builder used to deserialize the response - /// The resulting message of the service call - TMessage CallMethod(string method, IMessageLite request, - IBuilderLite response) - where TMessage : IMessageLite - where TBuilder : IBuilderLite; - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/IService.cs b/csharp/src/ProtocolBuffers/IService.cs deleted file mode 100644 index 61af35c1..00000000 --- a/csharp/src/ProtocolBuffers/IService.cs +++ /dev/null @@ -1,102 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ -// -// 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. - -#endregion - -using System; -using Google.ProtocolBuffers.Descriptors; - -namespace Google.ProtocolBuffers -{ - /// - /// Base interface for protocol-buffer-based RPC services. Services themselves - /// are abstract classes (implemented either by servers or as stubs) but they - /// implement this itnerface. The methods of this interface can be used to call - /// the methods of the service without knowing its exact type at compile time - /// (analagous to the IMessage interface). - /// - public interface IService - { - /// - /// The ServiceDescriptor describing this service and its methods. - /// - ServiceDescriptor DescriptorForType { get; } - - /// - /// Call a method of the service specified by MethodDescriptor. This is - /// normally implemented as a simple switch that calls the standard - /// definitions of the service's methods. - /// - /// Preconditions - /// - /// method.Service == DescriptorForType - /// request is of the exact same class as the object returned by GetRequestPrototype(method) - /// controller is of the correct type for the RPC implementation being used by this service. - /// For stubs, the "correct type" depends on the IRpcChannel which the stub is using. Server-side - /// implementations are expected to accept whatever type of IRpcController the server-side RPC implementation - /// uses. - /// - /// - /// - /// Postconditions - /// - /// will be called when the method is complete. - /// This may before CallMethod returns or it may be at some point in the future. - /// The parameter to is the response. It will be of the - /// exact same type as would be returned by . - /// If the RPC failed, the parameter to will be null. - /// Further details about the failure can be found by querying . - /// - /// - /// - void CallMethod(MethodDescriptor method, IRpcController controller, - IMessage request, Action done); - - /// - /// CallMethod requires that the request passed in is of a particular implementation - /// of IMessage. This method gets the default instance of this type of a given method. - /// You can then call WeakCreateBuilderForType to create a builder to build an object which - /// you can then pass to CallMethod. - /// - IMessage GetRequestPrototype(MethodDescriptor method); - - /// - /// Like GetRequestPrototype, but returns a prototype of the response message. - /// This is generally not needed because the IService implementation contructs - /// the response message itself, but it may be useful in some cases to know ahead - /// of time what type of object will be returned. - /// - IMessage GetResponsePrototype(MethodDescriptor method); - } -} \ No newline at end of file diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj index 4bb38de1..d9e50ec6 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffers.csproj @@ -123,16 +123,11 @@ - - - - - diff --git a/csharp/src/ProtocolBuffers/ProtocolBuffersLite.csproj b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.csproj index 4037c2bf..fa765147 100644 --- a/csharp/src/ProtocolBuffers/ProtocolBuffersLite.csproj +++ b/csharp/src/ProtocolBuffers/ProtocolBuffersLite.csproj @@ -75,7 +75,6 @@ - diff --git a/csharp/src/ProtocolBuffers/RpcUtil.cs b/csharp/src/ProtocolBuffers/RpcUtil.cs deleted file mode 100644 index 4659d86a..00000000 --- a/csharp/src/ProtocolBuffers/RpcUtil.cs +++ /dev/null @@ -1,79 +0,0 @@ -#region Copyright notice and license - -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// http://github.com/jskeet/dotnet-protobufs/ -// Original C++/Java/Python code: -// http://code.google.com/p/protobuf/ -// -// 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. - -#endregion - -using System; - -namespace Google.ProtocolBuffers -{ - /// - /// Grab-bag of utility functions useful when dealing with RPCs. - /// - public static class RpcUtil - { - /// - /// Converts an Action[IMessage] to an Action[T]. - /// - public static Action SpecializeCallback(Action action) - where T : IMessage - { - return message => action(message); - } - - /// - /// Converts an Action[T] to an Action[IMessage]. - /// The generalized action will accept any message object which has - /// the same descriptor, and will convert it to the correct class - /// before calling the original action. However, if the generalized - /// callback is given a message with a different descriptor, an - /// exception will be thrown. - /// - public static Action GeneralizeCallback(Action action, - TMessage defaultInstance) - where TMessage : class, IMessage - where TBuilder : IBuilder - { - return message => - { - TMessage castMessage = message as TMessage; - if (castMessage == null) - { - castMessage = defaultInstance.CreateBuilderForType().MergeFrom(message).Build(); - } - action(castMessage); - }; - } - } -} \ No newline at end of file -- cgit v1.2.3