aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--build.yaml2
-rw-r--r--composer.json2
-rw-r--r--examples/csharp/Greeter/Helloworld.cs617
-rw-r--r--examples/csharp/Greeter/HelloworldGrpc.cs78
-rw-r--r--examples/csharp/Greeter/packages.config11
-rw-r--r--examples/csharp/GreeterClient/Program.cs25
-rw-r--r--examples/csharp/GreeterClient/packages.config11
-rw-r--r--examples/csharp/GreeterServer/Program.cs37
-rw-r--r--examples/csharp/GreeterServer/packages.config11
-rw-r--r--examples/csharp/helloworld/.nuget/packages.config4
-rw-r--r--examples/csharp/helloworld/Greeter.sln (renamed from examples/csharp/Greeter.sln)0
-rw-r--r--examples/csharp/helloworld/Greeter/.gitignore (renamed from examples/csharp/Greeter/.gitignore)0
-rw-r--r--examples/csharp/helloworld/Greeter/Greeter.csproj (renamed from examples/csharp/Greeter/Greeter.csproj)33
-rw-r--r--examples/csharp/helloworld/Greeter/Helloworld.cs248
-rw-r--r--examples/csharp/helloworld/Greeter/HelloworldGrpc.cs89
-rw-r--r--examples/csharp/helloworld/Greeter/Properties/AssemblyInfo.cs (renamed from examples/csharp/Greeter/Properties/AssemblyInfo.cs)0
-rw-r--r--examples/csharp/helloworld/Greeter/packages.config10
-rw-r--r--examples/csharp/helloworld/GreeterClient/.gitignore (renamed from examples/csharp/GreeterClient/.gitignore)0
-rw-r--r--examples/csharp/helloworld/GreeterClient/GreeterClient.csproj (renamed from examples/csharp/GreeterClient/GreeterClient.csproj)33
-rw-r--r--examples/csharp/helloworld/GreeterClient/Program.cs24
-rw-r--r--examples/csharp/helloworld/GreeterClient/Properties/AssemblyInfo.cs (renamed from examples/csharp/GreeterClient/Properties/AssemblyInfo.cs)0
-rw-r--r--examples/csharp/helloworld/GreeterClient/packages.config10
-rw-r--r--examples/csharp/helloworld/GreeterServer/.gitignore (renamed from examples/csharp/GreeterServer/.gitignore)0
-rw-r--r--examples/csharp/helloworld/GreeterServer/GreeterServer.csproj (renamed from examples/csharp/GreeterServer/GreeterServer.csproj)33
-rw-r--r--examples/csharp/helloworld/GreeterServer/Program.cs37
-rw-r--r--examples/csharp/helloworld/GreeterServer/Properties/AssemblyInfo.cs (renamed from examples/csharp/GreeterServer/Properties/AssemblyInfo.cs)0
-rw-r--r--examples/csharp/helloworld/GreeterServer/packages.config10
-rw-r--r--examples/csharp/helloworld/README.md (renamed from examples/csharp/README.md)0
-rw-r--r--examples/csharp/helloworld/generate_protos.bat10
-rw-r--r--examples/csharp/route_guide/.nuget/packages.config2
-rw-r--r--examples/csharp/route_guide/README.md115
-rw-r--r--examples/csharp/route_guide/RouteGuide/RouteGuide.cs2033
-rw-r--r--examples/csharp/route_guide/RouteGuide/RouteGuide.csproj34
-rw-r--r--examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs122
-rw-r--r--examples/csharp/route_guide/RouteGuide/RouteGuideUtil.cs63
-rw-r--r--examples/csharp/route_guide/RouteGuide/packages.config11
-rw-r--r--examples/csharp/route_guide/RouteGuide/protos/route_guide.proto123
-rw-r--r--examples/csharp/route_guide/RouteGuideClient/Program.cs88
-rw-r--r--examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj33
-rw-r--r--examples/csharp/route_guide/RouteGuideClient/packages.config11
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/Program.cs16
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs128
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj33
-rw-r--r--examples/csharp/route_guide/RouteGuideServer/packages.config11
-rw-r--r--examples/csharp/route_guide/generate_protos.bat10
-rw-r--r--examples/node/route_guide/README.md27
-rw-r--r--examples/node/route_guide/route_guide.proto4
-rw-r--r--examples/node/route_guide/route_guide_client.js6
-rw-r--r--examples/node/route_guide/route_guide_server.js4
-rw-r--r--src/core/surface/version.c2
-rw-r--r--src/cpp/util/string_ref.cc1
-rw-r--r--src/csharp/build_packages.bat5
-rw-r--r--src/node/interop/interop_client.js8
-rw-r--r--src/node/src/client.js2
-rw-r--r--src/objective-c/examples/RemoteTestClient/RemoteTest.podspec28
-rw-r--r--src/objective-c/examples/RemoteTestClient/empty.proto (renamed from examples/csharp/Greeter/protos/helloworld.proto)32
-rw-r--r--src/objective-c/examples/RemoteTestClient/messages.proto133
-rw-r--r--src/objective-c/examples/RemoteTestClient/test.proto73
-rw-r--r--src/objective-c/examples/SwiftSample/AppDelegate.swift39
-rw-r--r--src/objective-c/examples/SwiftSample/Base.lproj/Main.storyboard25
-rw-r--r--src/objective-c/examples/SwiftSample/Bridging-Header.h44
-rw-r--r--src/objective-c/examples/SwiftSample/Images.xcassets/AppIcon.appiconset/Contents.json68
-rw-r--r--src/objective-c/examples/SwiftSample/Info.plist47
-rw-r--r--src/objective-c/examples/SwiftSample/Podfile8
-rw-r--r--src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj354
-rw-r--r--src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata7
-rw-r--r--src/objective-c/examples/SwiftSample/ViewController.swift77
-rw-r--r--src/php/composer.json2
-rw-r--r--src/php/ext/grpc/README.md23
-rw-r--r--src/php/ext/grpc/call.c27
-rw-r--r--src/php/ext/grpc/package.xml57
-rw-r--r--src/php/lib/Grpc/AbstractCall.php2
-rwxr-xr-xsrc/php/lib/Grpc/BaseStub.php13
-rw-r--r--src/php/lib/Grpc/BidiStreamingCall.php14
-rw-r--r--src/php/lib/Grpc/ClientStreamingCall.php23
-rw-r--r--src/php/lib/Grpc/ServerStreamingCall.php16
-rw-r--r--src/php/lib/Grpc/UnaryCall.php14
-rw-r--r--src/php/tests/generated_code/AbstractGeneratedCodeTest.php26
-rwxr-xr-xsrc/php/tests/interop/interop_client.php28
-rwxr-xr-xsrc/php/tests/unit_tests/EndToEndTest.php49
-rwxr-xr-xsrc/php/tests/unit_tests/SecureEndToEndTest.php51
-rw-r--r--src/python/README.md2
-rw-r--r--src/python/grpcio/grpc/_adapter/_c/types.h2
-rw-r--r--src/python/grpcio/grpc/_adapter/_c/types/call.c15
-rw-r--r--src/python/grpcio/grpc/_adapter/_intermediary_low.py3
-rw-r--r--src/python/grpcio/grpc/_adapter/_low.py3
-rw-r--r--src/python/grpcio/grpc/_links/_constants.py42
-rw-r--r--src/python/grpcio/grpc/_links/invocation.py8
-rw-r--r--src/python/grpcio/grpc/_links/service.py13
-rw-r--r--src/python/grpcio/grpc/beta/_server.py24
-rw-r--r--src/python/grpcio/grpc/beta/interfaces.py54
-rw-r--r--src/python/grpcio/grpc/framework/core/_constants.py17
-rw-r--r--src/python/grpcio/grpc/framework/core/_context.py10
-rw-r--r--src/python/grpcio/grpc/framework/core/_emission.py8
-rw-r--r--src/python/grpcio/grpc/framework/core/_end.py18
-rw-r--r--src/python/grpcio/grpc/framework/core/_expiration.py4
-rw-r--r--src/python/grpcio/grpc/framework/core/_ingestion.py31
-rw-r--r--src/python/grpcio/grpc/framework/core/_interfaces.py40
-rw-r--r--src/python/grpcio/grpc/framework/core/_operation.py8
-rw-r--r--src/python/grpcio/grpc/framework/core/_reception.py32
-rw-r--r--src/python/grpcio/grpc/framework/core/_termination.py34
-rw-r--r--src/python/grpcio/grpc/framework/core/_transmission.py108
-rw-r--r--src/python/grpcio/grpc/framework/core/_utilities.py8
-rw-r--r--src/python/grpcio/grpc/framework/crust/_calls.py2
-rw-r--r--src/python/grpcio/grpc/framework/crust/_control.py31
-rw-r--r--src/python/grpcio/grpc/framework/crust/_service.py2
-rw-r--r--src/python/grpcio/grpc/framework/crust/implementations.py13
-rw-r--r--src/python/grpcio/grpc/framework/interfaces/base/base.py41
-rw-r--r--src/python/grpcio/setup.py2
-rw-r--r--src/python/grpcio_test/grpc_test/_core_over_links_base_interface_test.py7
-rw-r--r--src/python/grpcio_test/grpc_test/_crust_over_core_over_links_face_interface_test.py3
-rw-r--r--src/python/grpcio_test/grpc_test/_links/_transmission_test.py10
-rw-r--r--src/python/grpcio_test/grpc_test/beta/_face_interface_test.py4
-rw-r--r--src/python/grpcio_test/grpc_test/beta/_not_found_test.py75
-rw-r--r--src/python/grpcio_test/grpc_test/framework/interfaces/base/_control.py20
-rw-r--r--src/python/grpcio_test/grpc_test/framework/interfaces/base/_sequence.py19
-rw-r--r--src/python/grpcio_test/grpc_test/framework/interfaces/base/test_cases.py14
-rw-r--r--src/python/grpcio_test/grpc_test/framework/interfaces/face/_blocking_invocation_inline_service.py8
-rw-r--r--tools/doxygen/Doxyfile.c++2
-rw-r--r--tools/doxygen/Doxyfile.c++.internal2
-rw-r--r--tools/doxygen/Doxyfile.core2
-rw-r--r--tools/doxygen/Doxyfile.core.internal2
-rwxr-xr-xtools/run_tests/build_php.sh3
-rwxr-xr-xtools/run_tests/run_interops.py4
-rw-r--r--vsprojects/nuget_package/buildall.bat2
-rw-r--r--vsprojects/nuget_package/grpc.native.csharp_ext.nuspec6
127 files changed, 3047 insertions, 3220 deletions
diff --git a/Makefile b/Makefile
index 281d8fb34c..91d8a0fbbd 100644
--- a/Makefile
+++ b/Makefile
@@ -309,7 +309,7 @@ E = @echo
Q = @
endif
-VERSION = 0.10.1.0
+VERSION = 0.11.0.0
CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
diff --git a/build.yaml b/build.yaml
index f9d767093b..d58ef16bf1 100644
--- a/build.yaml
+++ b/build.yaml
@@ -3,7 +3,7 @@
'#3': Please refer to the templates directory for more information.
settings:
'#': The public version number of the library.
- version: {major: 0, minor: 10, micro: 1, build: 0}
+ version: {major: 0, minor: 11, micro: 0, build: 0}
filegroups:
- name: census
public_headers: [include/grpc/census.h]
diff --git a/composer.json b/composer.json
index 1d78a2ce21..61f81e02bf 100644
--- a/composer.json
+++ b/composer.json
@@ -2,7 +2,7 @@
"name": "grpc/grpc",
"type": "library",
"description": "gRPC library for PHP",
- "version": "0.5.1",
+ "version": "0.6.0",
"keywords": ["rpc"],
"homepage": "http://grpc.io",
"license": "BSD-3-Clause",
diff --git a/examples/csharp/Greeter/Helloworld.cs b/examples/csharp/Greeter/Helloworld.cs
deleted file mode 100644
index 923a4271e9..0000000000
--- a/examples/csharp/Greeter/Helloworld.cs
+++ /dev/null
@@ -1,617 +0,0 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: helloworld.proto
-#pragma warning disable 1591, 0612, 3021
-#region Designer generated code
-
-using pb = global::Google.ProtocolBuffers;
-using pbc = global::Google.ProtocolBuffers.Collections;
-using pbd = global::Google.ProtocolBuffers.Descriptors;
-using scg = global::System.Collections.Generic;
-namespace helloworld {
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public static partial class Helloworld {
-
- #region Extension registration
- public static void RegisterAllExtensions(pb::ExtensionRegistry registry) {
- }
- #endregion
- #region Static variables
- internal static pbd::MessageDescriptor internal__static_helloworld_HelloRequest__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::helloworld.HelloRequest, global::helloworld.HelloRequest.Builder> internal__static_helloworld_HelloRequest__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_helloworld_HelloReply__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::helloworld.HelloReply, global::helloworld.HelloReply.Builder> internal__static_helloworld_HelloReply__FieldAccessorTable;
- #endregion
- #region Descriptor
- public static pbd::FileDescriptor Descriptor {
- get { return descriptor; }
- }
- private static pbd::FileDescriptor descriptor;
-
- static Helloworld() {
- byte[] descriptorData = global::System.Convert.FromBase64String(
- string.Concat(
- "ChBoZWxsb3dvcmxkLnByb3RvEgpoZWxsb3dvcmxkIhwKDEhlbGxvUmVxdWVz",
- "dBIMCgRuYW1lGAEgASgJIh0KCkhlbGxvUmVwbHkSDwoHbWVzc2FnZRgBIAEo",
- "CTJJCgdHcmVldGVyEj4KCFNheUhlbGxvEhguaGVsbG93b3JsZC5IZWxsb1Jl",
- "cXVlc3QaFi5oZWxsb3dvcmxkLkhlbGxvUmVwbHkiAEISChBpby5ncnBjLmV4",
- "YW1wbGVz"));
- pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) {
- descriptor = root;
- internal__static_helloworld_HelloRequest__Descriptor = Descriptor.MessageTypes[0];
- internal__static_helloworld_HelloRequest__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::helloworld.HelloRequest, global::helloworld.HelloRequest.Builder>(internal__static_helloworld_HelloRequest__Descriptor,
- new string[] { "Name", });
- internal__static_helloworld_HelloReply__Descriptor = Descriptor.MessageTypes[1];
- internal__static_helloworld_HelloReply__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::helloworld.HelloReply, global::helloworld.HelloReply.Builder>(internal__static_helloworld_HelloReply__Descriptor,
- new string[] { "Message", });
- pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance();
- RegisterAllExtensions(registry);
- return registry;
- };
- pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
- new pbd::FileDescriptor[] {
- }, assigner);
- }
- #endregion
-
- }
- #region Messages
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class HelloRequest : pb::GeneratedMessage<HelloRequest, HelloRequest.Builder> {
- private HelloRequest() { }
- private static readonly HelloRequest defaultInstance = new HelloRequest().MakeReadOnly();
- private static readonly string[] _helloRequestFieldNames = new string[] { "name" };
- private static readonly uint[] _helloRequestFieldTags = new uint[] { 10 };
- public static HelloRequest DefaultInstance {
- get { return defaultInstance; }
- }
-
- public override HelloRequest DefaultInstanceForType {
- get { return DefaultInstance; }
- }
-
- protected override HelloRequest ThisMessage {
- get { return this; }
- }
-
- public static pbd::MessageDescriptor Descriptor {
- get { return global::helloworld.Helloworld.internal__static_helloworld_HelloRequest__Descriptor; }
- }
-
- protected override pb::FieldAccess.FieldAccessorTable<HelloRequest, HelloRequest.Builder> InternalFieldAccessors {
- get { return global::helloworld.Helloworld.internal__static_helloworld_HelloRequest__FieldAccessorTable; }
- }
-
- public const int NameFieldNumber = 1;
- private bool hasName;
- private string name_ = "";
- public bool HasName {
- get { return hasName; }
- }
- public string Name {
- get { return name_; }
- }
-
- public override bool IsInitialized {
- get {
- return true;
- }
- }
-
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _helloRequestFieldNames;
- if (hasName) {
- output.WriteString(1, field_names[0], Name);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
- }
- }
-
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasName) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Name);
- }
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static HelloRequest ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static HelloRequest ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static HelloRequest ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static HelloRequest ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static HelloRequest ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static HelloRequest ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static HelloRequest ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static HelloRequest ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static HelloRequest ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static HelloRequest ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private HelloRequest MakeReadOnly() {
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(HelloRequest prototype) {
- return new Builder(prototype);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<HelloRequest, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
- }
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(HelloRequest cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private HelloRequest result;
-
- private HelloRequest PrepareBuilder() {
- if (resultIsReadOnly) {
- HelloRequest original = result;
- result = new HelloRequest();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
-
- protected override HelloRequest MessageBeingBuilt {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
- }
-
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::helloworld.HelloRequest.Descriptor; }
- }
-
- public override HelloRequest DefaultInstanceForType {
- get { return global::helloworld.HelloRequest.DefaultInstance; }
- }
-
- public override HelloRequest BuildPartial() {
- if (resultIsReadOnly) {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
- }
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is HelloRequest) {
- return MergeFrom((HelloRequest) other);
- } else {
- base.MergeFrom(other);
- return this;
- }
- }
-
- public override Builder MergeFrom(HelloRequest other) {
- if (other == global::helloworld.HelloRequest.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasName) {
- Name = other.Name;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_helloRequestFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _helloRequestFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
- }
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10: {
- result.hasName = input.ReadString(ref result.name_);
- break;
- }
- }
- }
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasName {
- get { return result.hasName; }
- }
- public string Name {
- get { return result.Name; }
- set { SetName(value); }
- }
- public Builder SetName(string value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasName = true;
- result.name_ = value;
- return this;
- }
- public Builder ClearName() {
- PrepareBuilder();
- result.hasName = false;
- result.name_ = "";
- return this;
- }
- }
- static HelloRequest() {
- object.ReferenceEquals(global::helloworld.Helloworld.Descriptor, null);
- }
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class HelloReply : pb::GeneratedMessage<HelloReply, HelloReply.Builder> {
- private HelloReply() { }
- private static readonly HelloReply defaultInstance = new HelloReply().MakeReadOnly();
- private static readonly string[] _helloReplyFieldNames = new string[] { "message" };
- private static readonly uint[] _helloReplyFieldTags = new uint[] { 10 };
- public static HelloReply DefaultInstance {
- get { return defaultInstance; }
- }
-
- public override HelloReply DefaultInstanceForType {
- get { return DefaultInstance; }
- }
-
- protected override HelloReply ThisMessage {
- get { return this; }
- }
-
- public static pbd::MessageDescriptor Descriptor {
- get { return global::helloworld.Helloworld.internal__static_helloworld_HelloReply__Descriptor; }
- }
-
- protected override pb::FieldAccess.FieldAccessorTable<HelloReply, HelloReply.Builder> InternalFieldAccessors {
- get { return global::helloworld.Helloworld.internal__static_helloworld_HelloReply__FieldAccessorTable; }
- }
-
- public const int MessageFieldNumber = 1;
- private bool hasMessage;
- private string message_ = "";
- public bool HasMessage {
- get { return hasMessage; }
- }
- public string Message {
- get { return message_; }
- }
-
- public override bool IsInitialized {
- get {
- return true;
- }
- }
-
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _helloReplyFieldNames;
- if (hasMessage) {
- output.WriteString(1, field_names[0], Message);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
- }
- }
-
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasMessage) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Message);
- }
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static HelloReply ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static HelloReply ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static HelloReply ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static HelloReply ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static HelloReply ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static HelloReply ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static HelloReply ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static HelloReply ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static HelloReply ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static HelloReply ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private HelloReply MakeReadOnly() {
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(HelloReply prototype) {
- return new Builder(prototype);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<HelloReply, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
- }
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(HelloReply cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private HelloReply result;
-
- private HelloReply PrepareBuilder() {
- if (resultIsReadOnly) {
- HelloReply original = result;
- result = new HelloReply();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
-
- protected override HelloReply MessageBeingBuilt {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
- }
-
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::helloworld.HelloReply.Descriptor; }
- }
-
- public override HelloReply DefaultInstanceForType {
- get { return global::helloworld.HelloReply.DefaultInstance; }
- }
-
- public override HelloReply BuildPartial() {
- if (resultIsReadOnly) {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
- }
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is HelloReply) {
- return MergeFrom((HelloReply) other);
- } else {
- base.MergeFrom(other);
- return this;
- }
- }
-
- public override Builder MergeFrom(HelloReply other) {
- if (other == global::helloworld.HelloReply.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasMessage) {
- Message = other.Message;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_helloReplyFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _helloReplyFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
- }
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10: {
- result.hasMessage = input.ReadString(ref result.message_);
- break;
- }
- }
- }
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasMessage {
- get { return result.hasMessage; }
- }
- public string Message {
- get { return result.Message; }
- set { SetMessage(value); }
- }
- public Builder SetMessage(string value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasMessage = true;
- result.message_ = value;
- return this;
- }
- public Builder ClearMessage() {
- PrepareBuilder();
- result.hasMessage = false;
- result.message_ = "";
- return this;
- }
- }
- static HelloReply() {
- object.ReferenceEquals(global::helloworld.Helloworld.Descriptor, null);
- }
- }
-
- #endregion
-
-}
-
-#endregion Designer generated code
diff --git a/examples/csharp/Greeter/HelloworldGrpc.cs b/examples/csharp/Greeter/HelloworldGrpc.cs
deleted file mode 100644
index 1ca9d2899b..0000000000
--- a/examples/csharp/Greeter/HelloworldGrpc.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-// Generated by the protocol buffer compiler. DO NOT EDIT!
-// source: helloworld.proto
-#region Designer generated code
-
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using Grpc.Core;
-
-namespace helloworld {
- public static class Greeter
- {
- static readonly string __ServiceName = "helloworld.Greeter";
-
- static readonly Marshaller<global::helloworld.HelloRequest> __Marshaller_HelloRequest = Marshallers.Create((arg) => arg.ToByteArray(), global::helloworld.HelloRequest.ParseFrom);
- static readonly Marshaller<global::helloworld.HelloReply> __Marshaller_HelloReply = Marshallers.Create((arg) => arg.ToByteArray(), global::helloworld.HelloReply.ParseFrom);
-
- static readonly Method<global::helloworld.HelloRequest, global::helloworld.HelloReply> __Method_SayHello = new Method<global::helloworld.HelloRequest, global::helloworld.HelloReply>(
- MethodType.Unary,
- "SayHello",
- __Marshaller_HelloRequest,
- __Marshaller_HelloReply);
-
- // client-side stub interface
- public interface IGreeterClient
- {
- global::helloworld.HelloReply SayHello(global::helloworld.HelloRequest request, CancellationToken token = default(CancellationToken));
- Task<global::helloworld.HelloReply> SayHelloAsync(global::helloworld.HelloRequest request, CancellationToken token = default(CancellationToken));
- }
-
- // server-side interface
- public interface IGreeter
- {
- Task<global::helloworld.HelloReply> SayHello(ServerCallContext context, global::helloworld.HelloRequest request);
- }
-
- // client stub
- public class GreeterClient : AbstractStub<GreeterClient, StubConfiguration>, IGreeterClient
- {
- public GreeterClient(Channel channel) : this(channel, StubConfiguration.Default)
- {
- }
- public GreeterClient(Channel channel, StubConfiguration config) : base(channel, config)
- {
- }
- public global::helloworld.HelloReply SayHello(global::helloworld.HelloRequest request, CancellationToken token = default(CancellationToken))
- {
- var call = CreateCall(__ServiceName, __Method_SayHello);
- return Calls.BlockingUnaryCall(call, request, token);
- }
- public Task<global::helloworld.HelloReply> SayHelloAsync(global::helloworld.HelloRequest request, CancellationToken token = default(CancellationToken))
- {
- var call = CreateCall(__ServiceName, __Method_SayHello);
- return Calls.AsyncUnaryCall(call, request, token);
- }
- }
-
- // creates service definition that can be registered with a server
- public static ServerServiceDefinition BindService(IGreeter serviceImpl)
- {
- return ServerServiceDefinition.CreateBuilder(__ServiceName)
- .AddMethod(__Method_SayHello, serviceImpl.SayHello).Build();
- }
-
- // creates a new client stub
- public static IGreeterClient NewStub(Channel channel)
- {
- return new GreeterClient(channel);
- }
-
- // creates a new client stub
- public static IGreeterClient NewStub(Channel channel, StubConfiguration config)
- {
- return new GreeterClient(channel, config);
- }
- }
-}
-#endregion
diff --git a/examples/csharp/Greeter/packages.config b/examples/csharp/Greeter/packages.config
deleted file mode 100644
index 5922553bc3..0000000000
--- a/examples/csharp/Greeter/packages.config
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net45" />
- <package id="Grpc" version="0.6.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.6.0" targetFramework="net45" />
- <package id="grpc.dependencies.openssl.redist" version="1.0.2.2" targetFramework="net45" />
- <package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.10.0" targetFramework="net45" />
- <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
-</packages> \ No newline at end of file
diff --git a/examples/csharp/GreeterClient/Program.cs b/examples/csharp/GreeterClient/Program.cs
deleted file mode 100644
index 61c29762b1..0000000000
--- a/examples/csharp/GreeterClient/Program.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using Grpc.Core;
-using helloworld;
-
-namespace GreeterClient
-{
- class ClientMainClass
- {
- public static void Main(string[] args)
- {
- GrpcEnvironment.Initialize();
-
- using (Channel channel = new Channel("127.0.0.1:50051"))
- {
- var client = Greeter.NewStub(channel);
- String user = "you";
-
- var reply = client.SayHello(new HelloRequest.Builder { Name = user }.Build());
- Console.WriteLine("Greeting: " + reply.Message);
- }
-
- GrpcEnvironment.Shutdown();
- }
- }
-}
diff --git a/examples/csharp/GreeterClient/packages.config b/examples/csharp/GreeterClient/packages.config
deleted file mode 100644
index 5922553bc3..0000000000
--- a/examples/csharp/GreeterClient/packages.config
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net45" />
- <package id="Grpc" version="0.6.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.6.0" targetFramework="net45" />
- <package id="grpc.dependencies.openssl.redist" version="1.0.2.2" targetFramework="net45" />
- <package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.10.0" targetFramework="net45" />
- <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
-</packages> \ No newline at end of file
diff --git a/examples/csharp/GreeterServer/Program.cs b/examples/csharp/GreeterServer/Program.cs
deleted file mode 100644
index 9482797c3b..0000000000
--- a/examples/csharp/GreeterServer/Program.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using Grpc.Core;
-using helloworld;
-
-namespace GreeterServer
-{
- class GreeterImpl : Greeter.IGreeter
- {
- // Server side handler of the SayHello RPC
- public Task<HelloReply> SayHello(ServerCallContext context, HelloRequest request)
- {
- var reply = new HelloReply.Builder { Message = "Hello " + request.Name }.Build();
- return Task.FromResult(reply);
- }
- }
-
- class ServerMainClass
- {
- public static void Main(string[] args)
- {
- GrpcEnvironment.Initialize();
-
- Server server = new Server();
- server.AddServiceDefinition(Greeter.BindService(new GreeterImpl()));
- int port = server.AddListeningPort("localhost", 50051);
- server.Start();
-
- Console.WriteLine("Greeter server listening on port " + port);
- Console.WriteLine("Press any key to stop the server...");
- Console.ReadKey();
-
- server.ShutdownAsync().Wait();
- GrpcEnvironment.Shutdown();
- }
- }
-}
diff --git a/examples/csharp/GreeterServer/packages.config b/examples/csharp/GreeterServer/packages.config
deleted file mode 100644
index 5922553bc3..0000000000
--- a/examples/csharp/GreeterServer/packages.config
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net45" />
- <package id="Grpc" version="0.6.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.6.0" targetFramework="net45" />
- <package id="grpc.dependencies.openssl.redist" version="1.0.2.2" targetFramework="net45" />
- <package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.10.0" targetFramework="net45" />
- <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
-</packages> \ No newline at end of file
diff --git a/examples/csharp/helloworld/.nuget/packages.config b/examples/csharp/helloworld/.nuget/packages.config
new file mode 100644
index 0000000000..e2879c1893
--- /dev/null
+++ b/examples/csharp/helloworld/.nuget/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Grpc.Tools" version="0.7.0" />
+</packages> \ No newline at end of file
diff --git a/examples/csharp/Greeter.sln b/examples/csharp/helloworld/Greeter.sln
index 9430e94de9..9430e94de9 100644
--- a/examples/csharp/Greeter.sln
+++ b/examples/csharp/helloworld/Greeter.sln
diff --git a/examples/csharp/Greeter/.gitignore b/examples/csharp/helloworld/Greeter/.gitignore
index 1746e3269e..1746e3269e 100644
--- a/examples/csharp/Greeter/.gitignore
+++ b/examples/csharp/helloworld/Greeter/.gitignore
diff --git a/examples/csharp/Greeter/Greeter.csproj b/examples/csharp/helloworld/Greeter/Greeter.csproj
index b8f965dbd2..3d92c4bf25 100644
--- a/examples/csharp/Greeter/Greeter.csproj
+++ b/examples/csharp/helloworld/Greeter/Greeter.csproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -13,7 +13,7 @@
<RootNamespace>Greeter</RootNamespace>
<AssemblyName>Greeter</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <NuGetPackageImportStamp>927432a0</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>3ef64a6a</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -34,21 +34,14 @@
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Google.ProtocolBuffers.Serialization">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
- </Reference>
- <Reference Include="Grpc.Core, Version=0.6.5668.37363, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.6.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
- </Reference>
<Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference>
@@ -70,12 +63,12 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
</Project> \ No newline at end of file
diff --git a/examples/csharp/helloworld/Greeter/Helloworld.cs b/examples/csharp/helloworld/Greeter/Helloworld.cs
new file mode 100644
index 0000000000..668165a6ce
--- /dev/null
+++ b/examples/csharp/helloworld/Greeter/Helloworld.cs
@@ -0,0 +1,248 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: helloworld.proto
+#pragma warning disable 1591, 0612, 3021
+#region Designer generated code
+
+using pb = global::Google.Protobuf;
+using pbc = global::Google.Protobuf.Collections;
+using pbr = global::Google.Protobuf.Reflection;
+using scg = global::System.Collections.Generic;
+namespace Helloworld {
+
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ public static partial class Helloworld {
+
+ #region Descriptor
+ public static pbr::FileDescriptor Descriptor {
+ get { return descriptor; }
+ }
+ private static pbr::FileDescriptor descriptor;
+
+ static Helloworld() {
+ byte[] descriptorData = global::System.Convert.FromBase64String(
+ string.Concat(
+ "ChBoZWxsb3dvcmxkLnByb3RvEgpoZWxsb3dvcmxkIhwKDEhlbGxvUmVxdWVz",
+ "dBIMCgRuYW1lGAEgASgJIh0KCkhlbGxvUmVwbHkSDwoHbWVzc2FnZRgBIAEo",
+ "CTJJCgdHcmVldGVyEj4KCFNheUhlbGxvEhguaGVsbG93b3JsZC5IZWxsb1Jl",
+ "cXVlc3QaFi5oZWxsb3dvcmxkLkhlbGxvUmVwbHkiAEIYChBpby5ncnBjLmV4",
+ "YW1wbGVzogIDSExXYgZwcm90bzM="));
+ descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
+ new pbr::FileDescriptor[] { },
+ new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] {
+ new pbr::GeneratedCodeInfo(typeof(global::Helloworld.HelloRequest), new[]{ "Name" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Helloworld.HelloReply), new[]{ "Message" }, null, null, null)
+ }));
+ }
+ #endregion
+
+ }
+ #region Messages
+ [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());
+ public static pb::MessageParser<HelloRequest> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Helloworld.Helloworld.Descriptor.MessageTypes[0]; }
+ }
+
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ public HelloRequest() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ public HelloRequest(HelloRequest other) : this() {
+ name_ = other.name_;
+ }
+
+ public HelloRequest Clone() {
+ return new HelloRequest(this);
+ }
+
+ public const int NameFieldNumber = 1;
+ private string name_ = "";
+ public string Name {
+ get { return name_; }
+ set {
+ name_ = pb::Preconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ public override bool Equals(object other) {
+ return Equals(other as HelloRequest);
+ }
+
+ public bool Equals(HelloRequest other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (Name != other.Name) return false;
+ return true;
+ }
+
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Name.Length != 0) hash ^= Name.GetHashCode();
+ return hash;
+ }
+
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
+
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Name.Length != 0) {
+ output.WriteRawTag(10);
+ output.WriteString(Name);
+ }
+ }
+
+ public int CalculateSize() {
+ int size = 0;
+ if (Name.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
+ }
+ return size;
+ }
+
+ public void MergeFrom(HelloRequest other) {
+ if (other == null) {
+ return;
+ }
+ if (other.Name.Length != 0) {
+ Name = other.Name;
+ }
+ }
+
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ Name = input.ReadString();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ [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());
+ public static pb::MessageParser<HelloReply> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Helloworld.Helloworld.Descriptor.MessageTypes[1]; }
+ }
+
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ public HelloReply() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ public HelloReply(HelloReply other) : this() {
+ message_ = other.message_;
+ }
+
+ public HelloReply Clone() {
+ return new HelloReply(this);
+ }
+
+ public const int MessageFieldNumber = 1;
+ private string message_ = "";
+ public string Message {
+ get { return message_; }
+ set {
+ message_ = pb::Preconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ public override bool Equals(object other) {
+ return Equals(other as HelloReply);
+ }
+
+ public bool Equals(HelloReply other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (Message != other.Message) return false;
+ return true;
+ }
+
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Message.Length != 0) hash ^= Message.GetHashCode();
+ return hash;
+ }
+
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
+
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Message.Length != 0) {
+ output.WriteRawTag(10);
+ output.WriteString(Message);
+ }
+ }
+
+ public int CalculateSize() {
+ int size = 0;
+ if (Message.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Message);
+ }
+ return size;
+ }
+
+ public void MergeFrom(HelloReply other) {
+ if (other == null) {
+ return;
+ }
+ if (other.Message.Length != 0) {
+ Message = other.Message;
+ }
+ }
+
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ Message = input.ReadString();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ #endregion
+
+}
+
+#endregion Designer generated code
diff --git a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs
new file mode 100644
index 0000000000..edfe4d2257
--- /dev/null
+++ b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs
@@ -0,0 +1,89 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: helloworld.proto
+#region Designer generated code
+
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using Grpc.Core;
+
+namespace Helloworld {
+ public static 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 Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply> __Method_SayHello = new Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply>(
+ MethodType.Unary,
+ __ServiceName,
+ "SayHello",
+ __Marshaller_HelloRequest,
+ __Marshaller_HelloReply);
+
+ // service descriptor
+ public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
+ {
+ get { return global::Helloworld.Helloworld.Descriptor.Services[0]; }
+ }
+
+ // client interface
+ public interface IGreeterClient
+ {
+ global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, CallOptions options);
+ AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, CallOptions options);
+ }
+
+ // server-side interface
+ public interface IGreeter
+ {
+ Task<global::Helloworld.HelloReply> SayHello(global::Helloworld.HelloRequest request, ServerCallContext context);
+ }
+
+ // client stub
+ public class GreeterClient : ClientBase, IGreeterClient
+ {
+ public GreeterClient(Channel channel) : base(channel)
+ {
+ }
+ public global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var call = CreateCall(__Method_SayHello, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.BlockingUnaryCall(call, request);
+ }
+ public global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, CallOptions options)
+ {
+ var call = CreateCall(__Method_SayHello, options);
+ return Calls.BlockingUnaryCall(call, request);
+ }
+ public AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var call = CreateCall(__Method_SayHello, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.AsyncUnaryCall(call, request);
+ }
+ public AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, CallOptions options)
+ {
+ var call = CreateCall(__Method_SayHello, options);
+ return Calls.AsyncUnaryCall(call, request);
+ }
+ }
+
+ // creates service definition that can be registered with a server
+ public static ServerServiceDefinition BindService(IGreeter serviceImpl)
+ {
+ return ServerServiceDefinition.CreateBuilder(__ServiceName)
+ .AddMethod(__Method_SayHello, serviceImpl.SayHello).Build();
+ }
+
+ // creates a new client
+ public static GreeterClient NewClient(Channel channel)
+ {
+ return new GreeterClient(channel);
+ }
+
+ }
+}
+#endregion
diff --git a/examples/csharp/Greeter/Properties/AssemblyInfo.cs b/examples/csharp/helloworld/Greeter/Properties/AssemblyInfo.cs
index b9d0dc264d..b9d0dc264d 100644
--- a/examples/csharp/Greeter/Properties/AssemblyInfo.cs
+++ b/examples/csharp/helloworld/Greeter/Properties/AssemblyInfo.cs
diff --git a/examples/csharp/helloworld/Greeter/packages.config b/examples/csharp/helloworld/Greeter/packages.config
new file mode 100644
index 0000000000..1273624cbd
--- /dev/null
+++ b/examples/csharp/helloworld/Greeter/packages.config
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
+ <package id="Grpc" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
+ <package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
+ <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
+</packages> \ No newline at end of file
diff --git a/examples/csharp/GreeterClient/.gitignore b/examples/csharp/helloworld/GreeterClient/.gitignore
index 1746e3269e..1746e3269e 100644
--- a/examples/csharp/GreeterClient/.gitignore
+++ b/examples/csharp/helloworld/GreeterClient/.gitignore
diff --git a/examples/csharp/GreeterClient/GreeterClient.csproj b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj
index 59b768af01..7874172bf2 100644
--- a/examples/csharp/GreeterClient/GreeterClient.csproj
+++ b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -13,7 +13,7 @@
<RootNamespace>GreeterClient</RootNamespace>
<AssemblyName>GreeterClient</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <NuGetPackageImportStamp>985ca8be</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>c4057b0a</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -34,21 +34,14 @@
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Google.ProtocolBuffers.Serialization">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
- </Reference>
- <Reference Include="Grpc.Core, Version=0.6.5668.37363, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.6.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
- </Reference>
<Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference>
@@ -73,12 +66,12 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
</Project> \ No newline at end of file
diff --git a/examples/csharp/helloworld/GreeterClient/Program.cs b/examples/csharp/helloworld/GreeterClient/Program.cs
new file mode 100644
index 0000000000..279cee07e1
--- /dev/null
+++ b/examples/csharp/helloworld/GreeterClient/Program.cs
@@ -0,0 +1,24 @@
+using System;
+using Grpc.Core;
+using Helloworld;
+
+namespace GreeterClient
+{
+ class Program
+ {
+ public static void Main(string[] args)
+ {
+ Channel channel = new Channel("127.0.0.1:50051", Credentials.Insecure);
+
+ var client = Greeter.NewClient(channel);
+ String user = "you";
+
+ var reply = client.SayHello(new HelloRequest { Name = user });
+ Console.WriteLine("Greeting: " + reply.Message);
+
+ channel.ShutdownAsync().Wait();
+ Console.WriteLine("Press any key to exit...");
+ Console.ReadKey();
+ }
+ }
+}
diff --git a/examples/csharp/GreeterClient/Properties/AssemblyInfo.cs b/examples/csharp/helloworld/GreeterClient/Properties/AssemblyInfo.cs
index 1422e952d8..1422e952d8 100644
--- a/examples/csharp/GreeterClient/Properties/AssemblyInfo.cs
+++ b/examples/csharp/helloworld/GreeterClient/Properties/AssemblyInfo.cs
diff --git a/examples/csharp/helloworld/GreeterClient/packages.config b/examples/csharp/helloworld/GreeterClient/packages.config
new file mode 100644
index 0000000000..1273624cbd
--- /dev/null
+++ b/examples/csharp/helloworld/GreeterClient/packages.config
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
+ <package id="Grpc" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
+ <package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
+ <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
+</packages> \ No newline at end of file
diff --git a/examples/csharp/GreeterServer/.gitignore b/examples/csharp/helloworld/GreeterServer/.gitignore
index 1746e3269e..1746e3269e 100644
--- a/examples/csharp/GreeterServer/.gitignore
+++ b/examples/csharp/helloworld/GreeterServer/.gitignore
diff --git a/examples/csharp/GreeterServer/GreeterServer.csproj b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj
index cd50d6cd52..d1db2f4773 100644
--- a/examples/csharp/GreeterServer/GreeterServer.csproj
+++ b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -13,7 +13,7 @@
<RootNamespace>GreeterServer</RootNamespace>
<AssemblyName>GreeterServer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
- <NuGetPackageImportStamp>a1eeb1d8</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>cc15afe5</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -34,21 +34,14 @@
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Google.ProtocolBuffers.Serialization">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
- </Reference>
- <Reference Include="Grpc.Core, Version=0.6.5668.37363, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.6.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
- </Reference>
<Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference>
@@ -73,12 +66,12 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
</Project> \ No newline at end of file
diff --git a/examples/csharp/helloworld/GreeterServer/Program.cs b/examples/csharp/helloworld/GreeterServer/Program.cs
new file mode 100644
index 0000000000..0214b359a9
--- /dev/null
+++ b/examples/csharp/helloworld/GreeterServer/Program.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Threading.Tasks;
+using Grpc.Core;
+using Helloworld;
+
+namespace GreeterServer
+{
+ class GreeterImpl : Greeter.IGreeter
+ {
+ // Server side handler of the SayHello RPC
+ public Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context)
+ {
+ return Task.FromResult(new HelloReply { Message = "Hello " + request.Name });
+ }
+ }
+
+ class Program
+ {
+ const int Port = 50051;
+
+ public static void Main(string[] args)
+ {
+ Server server = new Server
+ {
+ Services = { Greeter.BindService(new GreeterImpl()) },
+ Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
+ };
+ server.Start();
+
+ Console.WriteLine("Greeter server listening on port " + Port);
+ Console.WriteLine("Press any key to stop the server...");
+ Console.ReadKey();
+
+ server.ShutdownAsync().Wait();
+ }
+ }
+}
diff --git a/examples/csharp/GreeterServer/Properties/AssemblyInfo.cs b/examples/csharp/helloworld/GreeterServer/Properties/AssemblyInfo.cs
index f8a8d521d8..f8a8d521d8 100644
--- a/examples/csharp/GreeterServer/Properties/AssemblyInfo.cs
+++ b/examples/csharp/helloworld/GreeterServer/Properties/AssemblyInfo.cs
diff --git a/examples/csharp/helloworld/GreeterServer/packages.config b/examples/csharp/helloworld/GreeterServer/packages.config
new file mode 100644
index 0000000000..1273624cbd
--- /dev/null
+++ b/examples/csharp/helloworld/GreeterServer/packages.config
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
+ <package id="Grpc" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
+ <package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
+ <package id="Ix-Async" version="1.2.3" targetFramework="net45" />
+</packages> \ No newline at end of file
diff --git a/examples/csharp/README.md b/examples/csharp/helloworld/README.md
index 3719080f4a..3719080f4a 100644
--- a/examples/csharp/README.md
+++ b/examples/csharp/helloworld/README.md
diff --git a/examples/csharp/helloworld/generate_protos.bat b/examples/csharp/helloworld/generate_protos.bat
new file mode 100644
index 0000000000..9a5a9d3ee3
--- /dev/null
+++ b/examples/csharp/helloworld/generate_protos.bat
@@ -0,0 +1,10 @@
+@rem Generate the C# code for .proto files
+
+setlocal
+
+@rem enter this directory
+cd /d %~dp0
+
+packages\Google.Protobuf.3.0.0-alpha4\tools\protoc.exe -I../../protos --csharp_out Greeter ../../protos/helloworld.proto --grpc_out Greeter --plugin=protoc-gen-grpc=packages\Grpc.Tools.0.7.0\tools\grpc_csharp_plugin.exe
+
+endlocal \ No newline at end of file
diff --git a/examples/csharp/route_guide/.nuget/packages.config b/examples/csharp/route_guide/.nuget/packages.config
index b14373069f..e2879c1893 100644
--- a/examples/csharp/route_guide/.nuget/packages.config
+++ b/examples/csharp/route_guide/.nuget/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Grpc.Tools" version="0.6.0" />
+ <package id="Grpc.Tools" version="0.7.0" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/README.md b/examples/csharp/route_guide/README.md
index ec9a0c048e..155877e62e 100644
--- a/examples/csharp/route_guide/README.md
+++ b/examples/csharp/route_guide/README.md
@@ -93,16 +93,16 @@ message Point {
Next we need to generate the gRPC client and server interfaces from our .proto service definition. We do this using the protocol buffer compiler `protoc` with a special gRPC C# plugin.
If you want to run this yourself, make sure you've installed protoc and gRPC C# plugin. The instructions vary based on your OS:
-- For Windows, the `Grpc.Tools` NuGet package contains the binaries you will need to generate the code.
+- For Windows, the `Grpc.Tools` and `Google.Protobuf` NuGet packages contain the binaries you will need to generate the code.
- For Linux, make sure you've [installed gRPC C Core using Linuxbrew](https://github.com/grpc/grpc/tree/master/src/csharp#usage-linux-mono)
- For MacOS, make sure you've [installed gRPC C Core using Homebrew](https://github.com/grpc/grpc/tree/master/src/csharp#usage-macos-mono)
Once that's done, the following command can be used to generate the C# code.
-To generate the code on Windows, we use `protoc.exe` and `grpc_csharp_plugin.exe` binaries that are shipped with the `Grpc.Tools` NuGet package under the `tools` directory.
+To generate the code on Windows, we use `protoc.exe` from the `Google.Protobuf` NuGet package and `grpc_csharp_plugin.exe` from the `Grpc.Tools` NuGet package (both under the `tools` directory).
Normally you would need to add the `Grpc.Tools` package to the solution yourself, but in this tutorial it has been already done for you. Following command should be run from the `csharp/route_guide` directory:
```
-> packages\Grpc.Tools.0.5.1\tools\protoc -I RouteGuide/protos --csharp_out=RouteGuide --grpc_out=RouteGuide --plugin=protoc-gen-grpc=packages\Grpc.Tools.0.5.1\tools\grpc_csharp_plugin.exe RouteGuide/protos/route_guide.proto
+> packages\Google.Protobuf.3.0.0-alpha4\tools\protoc -I RouteGuide/protos --csharp_out=RouteGuide --grpc_out=RouteGuide --plugin=protoc-gen-grpc=packages\Grpc.Tools.0.7.0\tools\grpc_csharp_plugin.exe RouteGuide/protos/route_guide.proto
```
On Linux/MacOS, we rely on `protoc` and `grpc_csharp_plugin` being installed by Linuxbrew/Homebrew. Run this command from the route_guide directory:
@@ -143,7 +143,7 @@ public class RouteGuideImpl : RouteGuide.IRouteGuide
`RouteGuideImpl` implements all our service methods. Let's look at the simplest type first, `GetFeature`, which just gets a `Point` from the client and returns the corresponding feature information from its database in a `Feature`.
```csharp
- public Task<Feature> GetFeature(Grpc.Core.ServerCallContext context, Point request)
+ public Task<Feature> GetFeature(Point request, Grpc.Core.ServerCallContext context)
{
return Task.FromResult(CheckFeature(request));
}
@@ -159,27 +159,14 @@ Now let's look at something a bit more complicated - a streaming RPC. `ListFeatu
```csharp
// in RouteGuideImpl
- public async Task ListFeatures(Grpc.Core.ServerCallContext context, Rectangle request,
- Grpc.Core.IServerStreamWriter<Feature> responseStream)
+ public async Task ListFeatures(Rectangle request,
+ Grpc.Core.IServerStreamWriter<Feature> responseStream,
+ Grpc.Core.ServerCallContext context)
{
- int left = Math.Min(request.Lo.Longitude, request.Hi.Longitude);
- int right = Math.Max(request.Lo.Longitude, request.Hi.Longitude);
- int top = Math.Max(request.Lo.Latitude, request.Hi.Latitude);
- int bottom = Math.Min(request.Lo.Latitude, request.Hi.Latitude);
-
- foreach (var feature in features)
+ var responses = features.FindAll( (feature) => feature.Exists() && request.Contains(feature.Location) );
+ foreach (var response in responses)
{
- if (!RouteGuideUtil.Exists(feature))
- {
- continue;
- }
-
- int lat = feature.Location.Latitude;
- int lon = feature.Location.Longitude;
- if (lon >= left && lon <= right && lat >= bottom && lat <= top)
- {
- await responseStream.WriteAsync(feature);
- }
+ await responseStream.WriteAsync(response);
}
}
```
@@ -191,8 +178,8 @@ As you can see, here the request object is a `Rectangle` in which our client wan
Similarly, the client-side streaming method `RecordRoute` uses an [IAsyncEnumerator](https://github.com/Reactive-Extensions/Rx.NET/blob/master/Ix.NET/Source/System.Interactive.Async/IAsyncEnumerator.cs), to read the stream of requests using the async method `MoveNext` and the `Current` property.
```csharp
- public async Task<RouteSummary> RecordRoute(Grpc.Core.ServerCallContext context,
- Grpc.Core.IAsyncStreamReader<Point> requestStream)
+ public async Task<RouteSummary> RecordRoute(Grpc.Core.IAsyncStreamReader<Point> requestStream,
+ Grpc.Core.ServerCallContext context)
{
int pointCount = 0;
int featureCount = 0;
@@ -205,21 +192,26 @@ Similarly, the client-side streaming method `RecordRoute` uses an [IAsyncEnumera
{
var point = requestStream.Current;
pointCount++;
- if (RouteGuideUtil.Exists(CheckFeature(point)))
+ if (CheckFeature(point).Exists())
{
featureCount++;
}
if (previous != null)
{
- distance += (int) CalcDistance(previous, point);
+ distance += (int) previous.GetDistance(point);
}
previous = point;
}
stopwatch.Stop();
- return RouteSummary.CreateBuilder().SetPointCount(pointCount)
- .SetFeatureCount(featureCount).SetDistance(distance)
- .SetElapsedTime((int) (stopwatch.ElapsedMilliseconds / 1000)).Build();
+
+ return new RouteSummary
+ {
+ PointCount = pointCount,
+ FeatureCount = featureCount,
+ Distance = distance,
+ ElapsedTime = (int)(stopwatch.ElapsedMilliseconds / 1000)
+ };
}
```
@@ -228,28 +220,17 @@ Similarly, the client-side streaming method `RecordRoute` uses an [IAsyncEnumera
Finally, let's look at our bidirectional streaming RPC `RouteChat`.
```csharp
- public async Task RouteChat(Grpc.Core.ServerCallContext context,
- Grpc.Core.IAsyncStreamReader<RouteNote> requestStream, Grpc.Core.IServerStreamWriter<RouteNote> responseStream)
+ public async Task RouteChat(Grpc.Core.IAsyncStreamReader<RouteNote> requestStream,
+ Grpc.Core.IServerStreamWriter<RouteNote> responseStream,
+ Grpc.Core.ServerCallContext context,)
{
while (await requestStream.MoveNext())
- {
+ {
var note = requestStream.Current;
- List<RouteNote> notes = GetOrCreateNotes(note.Location);
-
- List<RouteNote> prevNotes;
- lock (notes)
- {
- prevNotes = new List<RouteNote>(notes);
- }
-
+ List<RouteNote> prevNotes = AddNoteForLocation(note.Location, note);
foreach (var prevNote in prevNotes)
{
await responseStream.WriteAsync(prevNote);
- }
-
- lock (notes)
- {
- notes.Add(note);
}
}
}
@@ -263,11 +244,12 @@ Once we've implemented all our methods, we also need to start up a gRPC server s
```csharp
var features = RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile);
-GrpcEnvironment.Initialize();
-Server server = new Server();
-server.AddServiceDefinition(RouteGuide.BindService(new RouteGuideImpl(features)));
-int port = server.AddListeningPort("localhost", 50052);
+Server server = new Server
+{
+ Services = { RouteGuide.BindService(new RouteGuideImpl(features)) },
+ Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
+};
server.Start();
Console.WriteLine("RouteGuide server listening on port " + port);
@@ -275,14 +257,13 @@ Console.WriteLine("Press any key to stop the server...");
Console.ReadKey();
server.ShutdownAsync().Wait();
-GrpcEnvironment.Shutdown();
```
As you can see, we build and start our server using `Grpc.Core.Server` class. To do this, we:
1. Create an instance of `Grpc.Core.Server`.
1. Create an instance of our service implementation class `RouteGuideImpl`.
-3. Register our service implementation with the server using the `AddServiceDefinition` method and the generated method `RouteGuide.BindService`.
-2. Specify the address and port we want to use to listen for client requests using the `AddListeningPort` method.
+3. Register our service implementation by adding its service definition to `Services` collection (We obtain the service definition from the generated `RouteGuide.BindService` method).
+2. Specify the address and port we want to use to listen for client requests. This is done by adding `ServerPort` to `Ports` collection.
4. Call `Start` on the server instance to start an RPC server for our service.
<a name="client"></a>
@@ -294,19 +275,15 @@ In this section, we'll look at creating a C# client for our `RouteGuide` service
To call service methods, we first need to create a *stub*.
-First, we need to create a gRPC client channel that will connect to gRPC server. Then, we use the `RouteGuide.NewStub` method of the `RouteGuide` class generated from our .proto.
+First, we need to create a gRPC client channel that will connect to gRPC server. Then, we use the `RouteGuide.NewClient` method of the `RouteGuide` class generated from our .proto.
```csharp
-GrpcEnvironment.Initialize();
+Channel channel = new Channel("127.0.0.1:50052", Credentials.Insecure)
+var client = new RouteGuideClient(RouteGuide.NewClient(channel));
-using (Channel channel = new Channel("127.0.0.1:50052"))
-{
- var client = RouteGuide.NewStub(channel);
-
- // YOUR CODE GOES HERE
-}
+// YOUR CODE GOES HERE
-GrpcEnvironment.Shutdown();
+channel.ShutdownAsync().Wait();
```
### Calling service methods
@@ -319,7 +296,7 @@ gRPC C# also provides a synchronous method stub, but only for simple (single req
Calling the simple RPC `GetFeature` in a synchronous way is nearly as straightforward as calling a local method.
```csharp
-Point request = Point.CreateBuilder().SetLatitude(409146138).SetLongitude(-746188906).Build();
+Point request = new Point { Latitude = 409146138, Longitude = -746188906 };
Feature feature = client.GetFeature(request);
```
@@ -327,7 +304,7 @@ As you can see, we create and populate a request protocol buffer object (in our
Alternatively, if you are in async context, you can call an asynchronous version of the method (and use `await` keyword to await the result):
```csharp
-Point request = Point.CreateBuilder().SetLatitude(409146138).SetLongitude(-746188906).Build();
+Point request = new Point { Latitude = 409146138, Longitude = -746188906 };
Feature feature = await client.GetFeatureAsync(request);
```
@@ -349,17 +326,17 @@ using (var call = client.ListFeatures(request))
```
The client-side streaming method `RecordRoute` is similar, except we use the property `RequestStream` to write the requests one by one using `WriteAsync` and eventually signal that no more request will be send using `CompleteAsync`. The method result can be obtained through the property
-`Result`.
+`ResponseAsync`.
```csharp
using (var call = client.RecordRoute())
{
foreach (var point in points)
- {
+ {
await call.RequestStream.WriteAsync(point);
}
await call.RequestStream.CompleteAsync();
- RouteSummary summary = await call.Result;
+ RouteSummary summary = await call.ResponseAsync;
}
```
@@ -374,7 +351,7 @@ Finally, let's look at our bidirectional streaming RPC `RouteChat`. In this case
{
var note = call.ResponseStream.Current;
Console.WriteLine("Received " + note);
- }
+ }
});
foreach (RouteNote request in requests)
@@ -382,7 +359,7 @@ Finally, let's look at our bidirectional streaming RPC `RouteChat`. In this case
await call.RequestStream.WriteAsync(request);
}
await call.RequestStream.CompleteAsync();
- await responseReaderTask;
+ await responseReaderTask;
}
```
diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs
index 80508bcd3f..9bc6f307d2 100644
--- a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs
+++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs
@@ -3,38 +3,22 @@
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
-using pb = global::Google.ProtocolBuffers;
-using pbc = global::Google.ProtocolBuffers.Collections;
-using pbd = global::Google.ProtocolBuffers.Descriptors;
+using pb = global::Google.Protobuf;
+using pbc = global::Google.Protobuf.Collections;
+using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
-namespace examples {
+namespace Examples {
namespace Proto {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class RouteGuide {
- #region Extension registration
- public static void RegisterAllExtensions(pb::ExtensionRegistry registry) {
- }
- #endregion
- #region Static variables
- internal static pbd::MessageDescriptor internal__static_examples_Point__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::examples.Point, global::examples.Point.Builder> internal__static_examples_Point__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_examples_Rectangle__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::examples.Rectangle, global::examples.Rectangle.Builder> internal__static_examples_Rectangle__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_examples_Feature__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::examples.Feature, global::examples.Feature.Builder> internal__static_examples_Feature__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_examples_RouteNote__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::examples.RouteNote, global::examples.RouteNote.Builder> internal__static_examples_RouteNote__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_examples_RouteSummary__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable<global::examples.RouteSummary, global::examples.RouteSummary.Builder> internal__static_examples_RouteSummary__FieldAccessorTable;
- #endregion
#region Descriptor
- public static pbd::FileDescriptor Descriptor {
+ public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
- private static pbd::FileDescriptor descriptor;
+ private static pbr::FileDescriptor descriptor;
static RouteGuide() {
byte[] descriptorData = global::System.Convert.FromBase64String(
@@ -52,36 +36,17 @@ namespace examples {
"dXJlcxITLmV4YW1wbGVzLlJlY3RhbmdsZRoRLmV4YW1wbGVzLkZlYXR1cmUi",
"ADABEjoKC1JlY29yZFJvdXRlEg8uZXhhbXBsZXMuUG9pbnQaFi5leGFtcGxl",
"cy5Sb3V0ZVN1bW1hcnkiACgBEjsKCVJvdXRlQ2hhdBITLmV4YW1wbGVzLlJv",
- "dXRlTm90ZRoTLmV4YW1wbGVzLlJvdXRlTm90ZSIAKAEwAQ=="));
- pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) {
- descriptor = root;
- internal__static_examples_Point__Descriptor = Descriptor.MessageTypes[0];
- internal__static_examples_Point__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::examples.Point, global::examples.Point.Builder>(internal__static_examples_Point__Descriptor,
- new string[] { "Latitude", "Longitude", });
- internal__static_examples_Rectangle__Descriptor = Descriptor.MessageTypes[1];
- internal__static_examples_Rectangle__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::examples.Rectangle, global::examples.Rectangle.Builder>(internal__static_examples_Rectangle__Descriptor,
- new string[] { "Lo", "Hi", });
- internal__static_examples_Feature__Descriptor = Descriptor.MessageTypes[2];
- internal__static_examples_Feature__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::examples.Feature, global::examples.Feature.Builder>(internal__static_examples_Feature__Descriptor,
- new string[] { "Name", "Location", });
- internal__static_examples_RouteNote__Descriptor = Descriptor.MessageTypes[3];
- internal__static_examples_RouteNote__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::examples.RouteNote, global::examples.RouteNote.Builder>(internal__static_examples_RouteNote__Descriptor,
- new string[] { "Location", "Message", });
- internal__static_examples_RouteSummary__Descriptor = Descriptor.MessageTypes[4];
- internal__static_examples_RouteSummary__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable<global::examples.RouteSummary, global::examples.RouteSummary.Builder>(internal__static_examples_RouteSummary__Descriptor,
- new string[] { "PointCount", "FeatureCount", "Distance", "ElapsedTime", });
- pb::ExtensionRegistry registry = pb::ExtensionRegistry.CreateInstance();
- RegisterAllExtensions(registry);
- return registry;
- };
- pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
- new pbd::FileDescriptor[] {
- }, assigner);
+ "dXRlTm90ZRoTLmV4YW1wbGVzLlJvdXRlTm90ZSIAKAEwAUIPCgdleC5ncnBj",
+ "ogIDUlRHYgZwcm90bzM="));
+ descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
+ new pbr::FileDescriptor[] { },
+ new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] {
+ new pbr::GeneratedCodeInfo(typeof(global::Examples.Point), new[]{ "Latitude", "Longitude" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Examples.Rectangle), new[]{ "Lo", "Hi" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Examples.Feature), new[]{ "Name", "Location" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Examples.RouteNote), new[]{ "Location", "Message" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Examples.RouteSummary), new[]{ "PointCount", "FeatureCount", "Distance", "ElapsedTime" }, null, null, null)
+ }));
}
#endregion
@@ -89,1781 +54,719 @@ namespace examples {
}
#region Messages
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Point : pb::GeneratedMessage<Point, Point.Builder> {
- private Point() { }
- private static readonly Point defaultInstance = new Point().MakeReadOnly();
- private static readonly string[] _pointFieldNames = new string[] { "latitude", "longitude" };
- private static readonly uint[] _pointFieldTags = new uint[] { 8, 16 };
- public static Point DefaultInstance {
- get { return defaultInstance; }
+ public sealed partial class Point : pb::IMessage<Point> {
+ private static readonly pb::MessageParser<Point> _parser = new pb::MessageParser<Point>(() => new Point());
+ public static pb::MessageParser<Point> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Examples.Proto.RouteGuide.Descriptor.MessageTypes[0]; }
}
- public override Point DefaultInstanceForType {
- get { return DefaultInstance; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
- protected override Point ThisMessage {
- get { return this; }
+ public Point() {
+ OnConstruction();
}
- public static pbd::MessageDescriptor Descriptor {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_Point__Descriptor; }
+ partial void OnConstruction();
+
+ public Point(Point other) : this() {
+ latitude_ = other.latitude_;
+ longitude_ = other.longitude_;
}
- protected override pb::FieldAccess.FieldAccessorTable<Point, Point.Builder> InternalFieldAccessors {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_Point__FieldAccessorTable; }
+ public Point Clone() {
+ return new Point(this);
}
public const int LatitudeFieldNumber = 1;
- private bool hasLatitude;
private int latitude_;
- public bool HasLatitude {
- get { return hasLatitude; }
- }
public int Latitude {
get { return latitude_; }
+ set {
+ latitude_ = value;
+ }
}
public const int LongitudeFieldNumber = 2;
- private bool hasLongitude;
private int longitude_;
- public bool HasLongitude {
- get { return hasLongitude; }
- }
public int Longitude {
get { return longitude_; }
- }
-
- public override bool IsInitialized {
- get {
- return true;
+ set {
+ longitude_ = value;
}
}
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _pointFieldNames;
- if (hasLatitude) {
- output.WriteInt32(1, field_names[0], Latitude);
- }
- if (hasLongitude) {
- output.WriteInt32(2, field_names[1], Longitude);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
- }
+ public override bool Equals(object other) {
+ return Equals(other as Point);
}
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasLatitude) {
- size += pb::CodedOutputStream.ComputeInt32Size(1, Latitude);
+ public bool Equals(Point other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
}
- if (hasLongitude) {
- size += pb::CodedOutputStream.ComputeInt32Size(2, Longitude);
+ if (ReferenceEquals(other, this)) {
+ return true;
}
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static Point ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static Point ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static Point ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static Point ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static Point ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static Point ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static Point ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static Point ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static Point ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static Point ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private Point MakeReadOnly() {
- return this;
+ if (Latitude != other.Latitude) return false;
+ if (Longitude != other.Longitude) return false;
+ return true;
}
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(Point prototype) {
- return new Builder(prototype);
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Latitude != 0) hash ^= Latitude.GetHashCode();
+ if (Longitude != 0) hash ^= Longitude.GetHashCode();
+ return hash;
}
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<Point, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
- }
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(Point cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private Point result;
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
- private Point PrepareBuilder() {
- if (resultIsReadOnly) {
- Point original = result;
- result = new Point();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Latitude != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(Latitude);
}
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
-
- protected override Point MessageBeingBuilt {
- get { return PrepareBuilder(); }
+ if (Longitude != 0) {
+ output.WriteRawTag(16);
+ output.WriteInt32(Longitude);
}
+ }
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
+ public int CalculateSize() {
+ int size = 0;
+ if (Latitude != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Latitude);
}
-
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::examples.Point.Descriptor; }
+ if (Longitude != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Longitude);
}
+ return size;
+ }
- public override Point DefaultInstanceForType {
- get { return global::examples.Point.DefaultInstance; }
+ public void MergeFrom(Point other) {
+ if (other == null) {
+ return;
}
-
- public override Point BuildPartial() {
- if (resultIsReadOnly) {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
+ if (other.Latitude != 0) {
+ Latitude = other.Latitude;
}
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is Point) {
- return MergeFrom((Point) other);
- } else {
- base.MergeFrom(other);
- return this;
- }
+ if (other.Longitude != 0) {
+ Longitude = other.Longitude;
}
+ }
- public override Builder MergeFrom(Point other) {
- if (other == global::examples.Point.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasLatitude) {
- Latitude = other.Latitude;
- }
- if (other.HasLongitude) {
- Longitude = other.Longitude;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_pointFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _pointFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ Latitude = input.ReadInt32();
+ break;
}
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 8: {
- result.hasLatitude = input.ReadInt32(ref result.latitude_);
- break;
- }
- case 16: {
- result.hasLongitude = input.ReadInt32(ref result.longitude_);
- break;
- }
+ case 16: {
+ Longitude = input.ReadInt32();
+ break;
}
}
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasLatitude {
- get { return result.hasLatitude; }
- }
- public int Latitude {
- get { return result.Latitude; }
- set { SetLatitude(value); }
- }
- public Builder SetLatitude(int value) {
- PrepareBuilder();
- result.hasLatitude = true;
- result.latitude_ = value;
- return this;
- }
- public Builder ClearLatitude() {
- PrepareBuilder();
- result.hasLatitude = false;
- result.latitude_ = 0;
- return this;
- }
-
- public bool HasLongitude {
- get { return result.hasLongitude; }
- }
- public int Longitude {
- get { return result.Longitude; }
- set { SetLongitude(value); }
- }
- public Builder SetLongitude(int value) {
- PrepareBuilder();
- result.hasLongitude = true;
- result.longitude_ = value;
- return this;
- }
- public Builder ClearLongitude() {
- PrepareBuilder();
- result.hasLongitude = false;
- result.longitude_ = 0;
- return this;
}
}
- static Point() {
- object.ReferenceEquals(global::examples.Proto.RouteGuide.Descriptor, null);
- }
+
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Rectangle : pb::GeneratedMessage<Rectangle, Rectangle.Builder> {
- private Rectangle() { }
- private static readonly Rectangle defaultInstance = new Rectangle().MakeReadOnly();
- private static readonly string[] _rectangleFieldNames = new string[] { "hi", "lo" };
- private static readonly uint[] _rectangleFieldTags = new uint[] { 18, 10 };
- public static Rectangle DefaultInstance {
- get { return defaultInstance; }
- }
+ public sealed partial class Rectangle : pb::IMessage<Rectangle> {
+ private static readonly pb::MessageParser<Rectangle> _parser = new pb::MessageParser<Rectangle>(() => new Rectangle());
+ public static pb::MessageParser<Rectangle> Parser { get { return _parser; } }
- public override Rectangle DefaultInstanceForType {
- get { return DefaultInstance; }
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Examples.Proto.RouteGuide.Descriptor.MessageTypes[1]; }
}
- protected override Rectangle ThisMessage {
- get { return this; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
- public static pbd::MessageDescriptor Descriptor {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_Rectangle__Descriptor; }
+ public Rectangle() {
+ OnConstruction();
}
- protected override pb::FieldAccess.FieldAccessorTable<Rectangle, Rectangle.Builder> InternalFieldAccessors {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_Rectangle__FieldAccessorTable; }
- }
+ partial void OnConstruction();
- public const int LoFieldNumber = 1;
- private bool hasLo;
- private global::examples.Point lo_;
- public bool HasLo {
- get { return hasLo; }
- }
- public global::examples.Point Lo {
- get { return lo_ ?? global::examples.Point.DefaultInstance; }
+ public Rectangle(Rectangle other) : this() {
+ Lo = other.lo_ != null ? other.Lo.Clone() : null;
+ Hi = other.hi_ != null ? other.Hi.Clone() : null;
}
- public const int HiFieldNumber = 2;
- private bool hasHi;
- private global::examples.Point hi_;
- public bool HasHi {
- get { return hasHi; }
- }
- public global::examples.Point Hi {
- get { return hi_ ?? global::examples.Point.DefaultInstance; }
+ public Rectangle Clone() {
+ return new Rectangle(this);
}
- public override bool IsInitialized {
- get {
- return true;
+ public const int LoFieldNumber = 1;
+ private global::Examples.Point lo_;
+ public global::Examples.Point Lo {
+ get { return lo_; }
+ set {
+ lo_ = value;
}
}
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _rectangleFieldNames;
- if (hasLo) {
- output.WriteMessage(1, field_names[1], Lo);
- }
- if (hasHi) {
- output.WriteMessage(2, field_names[0], Hi);
+ public const int HiFieldNumber = 2;
+ private global::Examples.Point hi_;
+ public global::Examples.Point Hi {
+ get { return hi_; }
+ set {
+ hi_ = value;
}
- UnknownFields.WriteTo(output);
}
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
- }
+ public override bool Equals(object other) {
+ return Equals(other as Rectangle);
}
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasLo) {
- size += pb::CodedOutputStream.ComputeMessageSize(1, Lo);
+ public bool Equals(Rectangle other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
}
- if (hasHi) {
- size += pb::CodedOutputStream.ComputeMessageSize(2, Hi);
+ if (ReferenceEquals(other, this)) {
+ return true;
}
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static Rectangle ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static Rectangle ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static Rectangle ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static Rectangle ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static Rectangle ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static Rectangle ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static Rectangle ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static Rectangle ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static Rectangle ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static Rectangle ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private Rectangle MakeReadOnly() {
- return this;
+ if (!object.Equals(Lo, other.Lo)) return false;
+ if (!object.Equals(Hi, other.Hi)) return false;
+ return true;
}
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(Rectangle prototype) {
- return new Builder(prototype);
+ public override int GetHashCode() {
+ int hash = 1;
+ if (lo_ != null) hash ^= Lo.GetHashCode();
+ if (hi_ != null) hash ^= Hi.GetHashCode();
+ return hash;
}
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<Rectangle, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
- }
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(Rectangle cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private Rectangle result;
-
- private Rectangle PrepareBuilder() {
- if (resultIsReadOnly) {
- Rectangle original = result;
- result = new Rectangle();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
- protected override Rectangle MessageBeingBuilt {
- get { return PrepareBuilder(); }
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (lo_ != null) {
+ output.WriteRawTag(10);
+ output.WriteMessage(Lo);
}
-
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
+ if (hi_ != null) {
+ output.WriteRawTag(18);
+ output.WriteMessage(Hi);
}
+ }
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
+ public int CalculateSize() {
+ int size = 0;
+ if (lo_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Lo);
}
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::examples.Rectangle.Descriptor; }
+ if (hi_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Hi);
}
+ return size;
+ }
- public override Rectangle DefaultInstanceForType {
- get { return global::examples.Rectangle.DefaultInstance; }
+ public void MergeFrom(Rectangle other) {
+ if (other == null) {
+ return;
}
-
- public override Rectangle BuildPartial() {
- if (resultIsReadOnly) {
- return result;
+ if (other.lo_ != null) {
+ if (lo_ == null) {
+ lo_ = new global::Examples.Point();
}
- resultIsReadOnly = true;
- return result.MakeReadOnly();
+ Lo.MergeFrom(other.Lo);
}
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is Rectangle) {
- return MergeFrom((Rectangle) other);
- } else {
- base.MergeFrom(other);
- return this;
+ if (other.hi_ != null) {
+ if (hi_ == null) {
+ hi_ = new global::Examples.Point();
}
+ Hi.MergeFrom(other.Hi);
}
+ }
- public override Builder MergeFrom(Rectangle other) {
- if (other == global::examples.Rectangle.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasLo) {
- MergeLo(other.Lo);
- }
- if (other.HasHi) {
- MergeHi(other.Hi);
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_rectangleFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _rectangleFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ if (lo_ == null) {
+ lo_ = new global::Examples.Point();
}
+ input.ReadMessage(lo_);
+ break;
}
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10: {
- global::examples.Point.Builder subBuilder = global::examples.Point.CreateBuilder();
- if (result.hasLo) {
- subBuilder.MergeFrom(Lo);
- }
- input.ReadMessage(subBuilder, extensionRegistry);
- Lo = subBuilder.BuildPartial();
- break;
- }
- case 18: {
- global::examples.Point.Builder subBuilder = global::examples.Point.CreateBuilder();
- if (result.hasHi) {
- subBuilder.MergeFrom(Hi);
- }
- input.ReadMessage(subBuilder, extensionRegistry);
- Hi = subBuilder.BuildPartial();
- break;
+ case 18: {
+ if (hi_ == null) {
+ hi_ = new global::Examples.Point();
}
+ input.ReadMessage(hi_);
+ break;
}
}
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasLo {
- get { return result.hasLo; }
- }
- public global::examples.Point Lo {
- get { return result.Lo; }
- set { SetLo(value); }
- }
- public Builder SetLo(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasLo = true;
- result.lo_ = value;
- return this;
- }
- public Builder SetLo(global::examples.Point.Builder builderForValue) {
- pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
- PrepareBuilder();
- result.hasLo = true;
- result.lo_ = builderForValue.Build();
- return this;
- }
- public Builder MergeLo(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- if (result.hasLo &&
- result.lo_ != global::examples.Point.DefaultInstance) {
- result.lo_ = global::examples.Point.CreateBuilder(result.lo_).MergeFrom(value).BuildPartial();
- } else {
- result.lo_ = value;
- }
- result.hasLo = true;
- return this;
- }
- public Builder ClearLo() {
- PrepareBuilder();
- result.hasLo = false;
- result.lo_ = null;
- return this;
- }
-
- public bool HasHi {
- get { return result.hasHi; }
- }
- public global::examples.Point Hi {
- get { return result.Hi; }
- set { SetHi(value); }
- }
- public Builder SetHi(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasHi = true;
- result.hi_ = value;
- return this;
- }
- public Builder SetHi(global::examples.Point.Builder builderForValue) {
- pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
- PrepareBuilder();
- result.hasHi = true;
- result.hi_ = builderForValue.Build();
- return this;
- }
- public Builder MergeHi(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- if (result.hasHi &&
- result.hi_ != global::examples.Point.DefaultInstance) {
- result.hi_ = global::examples.Point.CreateBuilder(result.hi_).MergeFrom(value).BuildPartial();
- } else {
- result.hi_ = value;
- }
- result.hasHi = true;
- return this;
}
- public Builder ClearHi() {
- PrepareBuilder();
- result.hasHi = false;
- result.hi_ = null;
- return this;
- }
- }
- static Rectangle() {
- object.ReferenceEquals(global::examples.Proto.RouteGuide.Descriptor, null);
}
+
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Feature : pb::GeneratedMessage<Feature, Feature.Builder> {
- private Feature() { }
- private static readonly Feature defaultInstance = new Feature().MakeReadOnly();
- private static readonly string[] _featureFieldNames = new string[] { "location", "name" };
- private static readonly uint[] _featureFieldTags = new uint[] { 18, 10 };
- public static Feature DefaultInstance {
- get { return defaultInstance; }
+ public sealed partial class Feature : pb::IMessage<Feature> {
+ private static readonly pb::MessageParser<Feature> _parser = new pb::MessageParser<Feature>(() => new Feature());
+ public static pb::MessageParser<Feature> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Examples.Proto.RouteGuide.Descriptor.MessageTypes[2]; }
}
- public override Feature DefaultInstanceForType {
- get { return DefaultInstance; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
- protected override Feature ThisMessage {
- get { return this; }
+ public Feature() {
+ OnConstruction();
}
- public static pbd::MessageDescriptor Descriptor {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_Feature__Descriptor; }
+ partial void OnConstruction();
+
+ public Feature(Feature other) : this() {
+ name_ = other.name_;
+ Location = other.location_ != null ? other.Location.Clone() : null;
}
- protected override pb::FieldAccess.FieldAccessorTable<Feature, Feature.Builder> InternalFieldAccessors {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_Feature__FieldAccessorTable; }
+ public Feature Clone() {
+ return new Feature(this);
}
public const int NameFieldNumber = 1;
- private bool hasName;
private string name_ = "";
- public bool HasName {
- get { return hasName; }
- }
public string Name {
get { return name_; }
- }
-
- public const int LocationFieldNumber = 2;
- private bool hasLocation;
- private global::examples.Point location_;
- public bool HasLocation {
- get { return hasLocation; }
- }
- public global::examples.Point Location {
- get { return location_ ?? global::examples.Point.DefaultInstance; }
- }
-
- public override bool IsInitialized {
- get {
- return true;
+ set {
+ name_ = pb::Preconditions.CheckNotNull(value, "value");
}
}
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _featureFieldNames;
- if (hasName) {
- output.WriteString(1, field_names[1], Name);
- }
- if (hasLocation) {
- output.WriteMessage(2, field_names[0], Location);
+ public const int LocationFieldNumber = 2;
+ private global::Examples.Point location_;
+ public global::Examples.Point Location {
+ get { return location_; }
+ set {
+ location_ = value;
}
- UnknownFields.WriteTo(output);
}
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
- }
+ public override bool Equals(object other) {
+ return Equals(other as Feature);
}
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasName) {
- size += pb::CodedOutputStream.ComputeStringSize(1, Name);
+ public bool Equals(Feature other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
}
- if (hasLocation) {
- size += pb::CodedOutputStream.ComputeMessageSize(2, Location);
+ if (ReferenceEquals(other, this)) {
+ return true;
}
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static Feature ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static Feature ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static Feature ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static Feature ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static Feature ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static Feature ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static Feature ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static Feature ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static Feature ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static Feature ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private Feature MakeReadOnly() {
- return this;
+ if (Name != other.Name) return false;
+ if (!object.Equals(Location, other.Location)) return false;
+ return true;
}
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(Feature prototype) {
- return new Builder(prototype);
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Name.Length != 0) hash ^= Name.GetHashCode();
+ if (location_ != null) hash ^= Location.GetHashCode();
+ return hash;
}
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<Feature, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
- }
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(Feature cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private Feature result;
-
- private Feature PrepareBuilder() {
- if (resultIsReadOnly) {
- Feature original = result;
- result = new Feature();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
- protected override Feature MessageBeingBuilt {
- get { return PrepareBuilder(); }
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Name.Length != 0) {
+ output.WriteRawTag(10);
+ output.WriteString(Name);
}
-
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
+ if (location_ != null) {
+ output.WriteRawTag(18);
+ output.WriteMessage(Location);
}
+ }
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
+ public int CalculateSize() {
+ int size = 0;
+ if (Name.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::examples.Feature.Descriptor; }
+ if (location_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Location);
}
+ return size;
+ }
- public override Feature DefaultInstanceForType {
- get { return global::examples.Feature.DefaultInstance; }
+ public void MergeFrom(Feature other) {
+ if (other == null) {
+ return;
}
-
- public override Feature BuildPartial() {
- if (resultIsReadOnly) {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
+ if (other.Name.Length != 0) {
+ Name = other.Name;
}
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is Feature) {
- return MergeFrom((Feature) other);
- } else {
- base.MergeFrom(other);
- return this;
+ if (other.location_ != null) {
+ if (location_ == null) {
+ location_ = new global::Examples.Point();
}
+ Location.MergeFrom(other.Location);
}
+ }
- public override Builder MergeFrom(Feature other) {
- if (other == global::examples.Feature.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasName) {
- Name = other.Name;
- }
- if (other.HasLocation) {
- MergeLocation(other.Location);
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_featureFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _featureFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ Name = input.ReadString();
+ break;
}
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10: {
- result.hasName = input.ReadString(ref result.name_);
- break;
- }
- case 18: {
- global::examples.Point.Builder subBuilder = global::examples.Point.CreateBuilder();
- if (result.hasLocation) {
- subBuilder.MergeFrom(Location);
- }
- input.ReadMessage(subBuilder, extensionRegistry);
- Location = subBuilder.BuildPartial();
- break;
+ case 18: {
+ if (location_ == null) {
+ location_ = new global::Examples.Point();
}
+ input.ReadMessage(location_);
+ break;
}
}
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasName {
- get { return result.hasName; }
- }
- public string Name {
- get { return result.Name; }
- set { SetName(value); }
- }
- public Builder SetName(string value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasName = true;
- result.name_ = value;
- return this;
- }
- public Builder ClearName() {
- PrepareBuilder();
- result.hasName = false;
- result.name_ = "";
- return this;
- }
-
- public bool HasLocation {
- get { return result.hasLocation; }
- }
- public global::examples.Point Location {
- get { return result.Location; }
- set { SetLocation(value); }
- }
- public Builder SetLocation(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasLocation = true;
- result.location_ = value;
- return this;
- }
- public Builder SetLocation(global::examples.Point.Builder builderForValue) {
- pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
- PrepareBuilder();
- result.hasLocation = true;
- result.location_ = builderForValue.Build();
- return this;
- }
- public Builder MergeLocation(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- if (result.hasLocation &&
- result.location_ != global::examples.Point.DefaultInstance) {
- result.location_ = global::examples.Point.CreateBuilder(result.location_).MergeFrom(value).BuildPartial();
- } else {
- result.location_ = value;
- }
- result.hasLocation = true;
- return this;
- }
- public Builder ClearLocation() {
- PrepareBuilder();
- result.hasLocation = false;
- result.location_ = null;
- return this;
}
}
- static Feature() {
- object.ReferenceEquals(global::examples.Proto.RouteGuide.Descriptor, null);
- }
+
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class RouteNote : pb::GeneratedMessage<RouteNote, RouteNote.Builder> {
- private RouteNote() { }
- private static readonly RouteNote defaultInstance = new RouteNote().MakeReadOnly();
- private static readonly string[] _routeNoteFieldNames = new string[] { "location", "message" };
- private static readonly uint[] _routeNoteFieldTags = new uint[] { 10, 18 };
- public static RouteNote DefaultInstance {
- get { return defaultInstance; }
+ public sealed partial class RouteNote : pb::IMessage<RouteNote> {
+ private static readonly pb::MessageParser<RouteNote> _parser = new pb::MessageParser<RouteNote>(() => new RouteNote());
+ public static pb::MessageParser<RouteNote> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Examples.Proto.RouteGuide.Descriptor.MessageTypes[3]; }
}
- public override RouteNote DefaultInstanceForType {
- get { return DefaultInstance; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
- protected override RouteNote ThisMessage {
- get { return this; }
+ public RouteNote() {
+ OnConstruction();
}
- public static pbd::MessageDescriptor Descriptor {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_RouteNote__Descriptor; }
+ partial void OnConstruction();
+
+ public RouteNote(RouteNote other) : this() {
+ Location = other.location_ != null ? other.Location.Clone() : null;
+ message_ = other.message_;
}
- protected override pb::FieldAccess.FieldAccessorTable<RouteNote, RouteNote.Builder> InternalFieldAccessors {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_RouteNote__FieldAccessorTable; }
+ public RouteNote Clone() {
+ return new RouteNote(this);
}
public const int LocationFieldNumber = 1;
- private bool hasLocation;
- private global::examples.Point location_;
- public bool HasLocation {
- get { return hasLocation; }
- }
- public global::examples.Point Location {
- get { return location_ ?? global::examples.Point.DefaultInstance; }
+ private global::Examples.Point location_;
+ public global::Examples.Point Location {
+ get { return location_; }
+ set {
+ location_ = value;
+ }
}
public const int MessageFieldNumber = 2;
- private bool hasMessage;
private string message_ = "";
- public bool HasMessage {
- get { return hasMessage; }
- }
public string Message {
get { return message_; }
- }
-
- public override bool IsInitialized {
- get {
- return true;
+ set {
+ message_ = pb::Preconditions.CheckNotNull(value, "value");
}
}
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _routeNoteFieldNames;
- if (hasLocation) {
- output.WriteMessage(1, field_names[0], Location);
- }
- if (hasMessage) {
- output.WriteString(2, field_names[1], Message);
- }
- UnknownFields.WriteTo(output);
+ public override bool Equals(object other) {
+ return Equals(other as RouteNote);
}
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
+ public bool Equals(RouteNote other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
}
- }
-
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasLocation) {
- size += pb::CodedOutputStream.ComputeMessageSize(1, Location);
- }
- if (hasMessage) {
- size += pb::CodedOutputStream.ComputeStringSize(2, Message);
+ if (ReferenceEquals(other, this)) {
+ return true;
}
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static RouteNote ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static RouteNote ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static RouteNote ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static RouteNote ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static RouteNote ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static RouteNote ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static RouteNote ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static RouteNote ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static RouteNote ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static RouteNote ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private RouteNote MakeReadOnly() {
- return this;
+ if (!object.Equals(Location, other.Location)) return false;
+ if (Message != other.Message) return false;
+ return true;
}
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(RouteNote prototype) {
- return new Builder(prototype);
+ public override int GetHashCode() {
+ int hash = 1;
+ if (location_ != null) hash ^= Location.GetHashCode();
+ if (Message.Length != 0) hash ^= Message.GetHashCode();
+ return hash;
}
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<RouteNote, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
- }
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(RouteNote cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private RouteNote result;
-
- private RouteNote PrepareBuilder() {
- if (resultIsReadOnly) {
- RouteNote original = result;
- result = new RouteNote();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
- protected override RouteNote MessageBeingBuilt {
- get { return PrepareBuilder(); }
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (location_ != null) {
+ output.WriteRawTag(10);
+ output.WriteMessage(Location);
}
-
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
+ if (Message.Length != 0) {
+ output.WriteRawTag(18);
+ output.WriteString(Message);
}
+ }
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
+ public int CalculateSize() {
+ int size = 0;
+ if (location_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Location);
}
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::examples.RouteNote.Descriptor; }
+ if (Message.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Message);
}
+ return size;
+ }
- public override RouteNote DefaultInstanceForType {
- get { return global::examples.RouteNote.DefaultInstance; }
+ public void MergeFrom(RouteNote other) {
+ if (other == null) {
+ return;
}
-
- public override RouteNote BuildPartial() {
- if (resultIsReadOnly) {
- return result;
+ if (other.location_ != null) {
+ if (location_ == null) {
+ location_ = new global::Examples.Point();
}
- resultIsReadOnly = true;
- return result.MakeReadOnly();
+ Location.MergeFrom(other.Location);
}
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is RouteNote) {
- return MergeFrom((RouteNote) other);
- } else {
- base.MergeFrom(other);
- return this;
- }
+ if (other.Message.Length != 0) {
+ Message = other.Message;
}
+ }
- public override Builder MergeFrom(RouteNote other) {
- if (other == global::examples.RouteNote.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasLocation) {
- MergeLocation(other.Location);
- }
- if (other.HasMessage) {
- Message = other.Message;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_routeNoteFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _routeNoteFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ if (location_ == null) {
+ location_ = new global::Examples.Point();
}
+ input.ReadMessage(location_);
+ break;
}
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10: {
- global::examples.Point.Builder subBuilder = global::examples.Point.CreateBuilder();
- if (result.hasLocation) {
- subBuilder.MergeFrom(Location);
- }
- input.ReadMessage(subBuilder, extensionRegistry);
- Location = subBuilder.BuildPartial();
- break;
- }
- case 18: {
- result.hasMessage = input.ReadString(ref result.message_);
- break;
- }
+ case 18: {
+ Message = input.ReadString();
+ break;
}
}
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasLocation {
- get { return result.hasLocation; }
- }
- public global::examples.Point Location {
- get { return result.Location; }
- set { SetLocation(value); }
- }
- public Builder SetLocation(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasLocation = true;
- result.location_ = value;
- return this;
- }
- public Builder SetLocation(global::examples.Point.Builder builderForValue) {
- pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
- PrepareBuilder();
- result.hasLocation = true;
- result.location_ = builderForValue.Build();
- return this;
- }
- public Builder MergeLocation(global::examples.Point value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- if (result.hasLocation &&
- result.location_ != global::examples.Point.DefaultInstance) {
- result.location_ = global::examples.Point.CreateBuilder(result.location_).MergeFrom(value).BuildPartial();
- } else {
- result.location_ = value;
- }
- result.hasLocation = true;
- return this;
- }
- public Builder ClearLocation() {
- PrepareBuilder();
- result.hasLocation = false;
- result.location_ = null;
- return this;
- }
-
- public bool HasMessage {
- get { return result.hasMessage; }
- }
- public string Message {
- get { return result.Message; }
- set { SetMessage(value); }
- }
- public Builder SetMessage(string value) {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasMessage = true;
- result.message_ = value;
- return this;
- }
- public Builder ClearMessage() {
- PrepareBuilder();
- result.hasMessage = false;
- result.message_ = "";
- return this;
}
}
- static RouteNote() {
- object.ReferenceEquals(global::examples.Proto.RouteGuide.Descriptor, null);
- }
+
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class RouteSummary : pb::GeneratedMessage<RouteSummary, RouteSummary.Builder> {
- private RouteSummary() { }
- private static readonly RouteSummary defaultInstance = new RouteSummary().MakeReadOnly();
- private static readonly string[] _routeSummaryFieldNames = new string[] { "distance", "elapsed_time", "feature_count", "point_count" };
- private static readonly uint[] _routeSummaryFieldTags = new uint[] { 24, 32, 16, 8 };
- public static RouteSummary DefaultInstance {
- get { return defaultInstance; }
+ public sealed partial class RouteSummary : pb::IMessage<RouteSummary> {
+ private static readonly pb::MessageParser<RouteSummary> _parser = new pb::MessageParser<RouteSummary>(() => new RouteSummary());
+ public static pb::MessageParser<RouteSummary> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Examples.Proto.RouteGuide.Descriptor.MessageTypes[4]; }
}
- public override RouteSummary DefaultInstanceForType {
- get { return DefaultInstance; }
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
}
- protected override RouteSummary ThisMessage {
- get { return this; }
+ public RouteSummary() {
+ OnConstruction();
}
- public static pbd::MessageDescriptor Descriptor {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_RouteSummary__Descriptor; }
+ partial void OnConstruction();
+
+ public RouteSummary(RouteSummary other) : this() {
+ pointCount_ = other.pointCount_;
+ featureCount_ = other.featureCount_;
+ distance_ = other.distance_;
+ elapsedTime_ = other.elapsedTime_;
}
- protected override pb::FieldAccess.FieldAccessorTable<RouteSummary, RouteSummary.Builder> InternalFieldAccessors {
- get { return global::examples.Proto.RouteGuide.internal__static_examples_RouteSummary__FieldAccessorTable; }
+ public RouteSummary Clone() {
+ return new RouteSummary(this);
}
public const int PointCountFieldNumber = 1;
- private bool hasPointCount;
private int pointCount_;
- public bool HasPointCount {
- get { return hasPointCount; }
- }
public int PointCount {
get { return pointCount_; }
+ set {
+ pointCount_ = value;
+ }
}
public const int FeatureCountFieldNumber = 2;
- private bool hasFeatureCount;
private int featureCount_;
- public bool HasFeatureCount {
- get { return hasFeatureCount; }
- }
public int FeatureCount {
get { return featureCount_; }
+ set {
+ featureCount_ = value;
+ }
}
public const int DistanceFieldNumber = 3;
- private bool hasDistance;
private int distance_;
- public bool HasDistance {
- get { return hasDistance; }
- }
public int Distance {
get { return distance_; }
+ set {
+ distance_ = value;
+ }
}
public const int ElapsedTimeFieldNumber = 4;
- private bool hasElapsedTime;
private int elapsedTime_;
- public bool HasElapsedTime {
- get { return hasElapsedTime; }
- }
public int ElapsedTime {
get { return elapsedTime_; }
+ set {
+ elapsedTime_ = value;
+ }
}
- public override bool IsInitialized {
- get {
- return true;
- }
+ public override bool Equals(object other) {
+ return Equals(other as RouteSummary);
}
- public override void WriteTo(pb::ICodedOutputStream output) {
- CalcSerializedSize();
- string[] field_names = _routeSummaryFieldNames;
- if (hasPointCount) {
- output.WriteInt32(1, field_names[3], PointCount);
- }
- if (hasFeatureCount) {
- output.WriteInt32(2, field_names[2], FeatureCount);
- }
- if (hasDistance) {
- output.WriteInt32(3, field_names[0], Distance);
+ public bool Equals(RouteSummary other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
}
- if (hasElapsedTime) {
- output.WriteInt32(4, field_names[1], ElapsedTime);
+ if (ReferenceEquals(other, this)) {
+ return true;
}
- UnknownFields.WriteTo(output);
+ if (PointCount != other.PointCount) return false;
+ if (FeatureCount != other.FeatureCount) return false;
+ if (Distance != other.Distance) return false;
+ if (ElapsedTime != other.ElapsedTime) return false;
+ return true;
}
- private int memoizedSerializedSize = -1;
- public override int SerializedSize {
- get {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
- return CalcSerializedSize();
- }
+ public override int GetHashCode() {
+ int hash = 1;
+ if (PointCount != 0) hash ^= PointCount.GetHashCode();
+ if (FeatureCount != 0) hash ^= FeatureCount.GetHashCode();
+ if (Distance != 0) hash ^= Distance.GetHashCode();
+ if (ElapsedTime != 0) hash ^= ElapsedTime.GetHashCode();
+ return hash;
}
- private int CalcSerializedSize() {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
+ public override string ToString() {
+ return pb::JsonFormatter.Default.Format(this);
+ }
- size = 0;
- if (hasPointCount) {
- size += pb::CodedOutputStream.ComputeInt32Size(1, PointCount);
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (PointCount != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(PointCount);
}
- if (hasFeatureCount) {
- size += pb::CodedOutputStream.ComputeInt32Size(2, FeatureCount);
+ if (FeatureCount != 0) {
+ output.WriteRawTag(16);
+ output.WriteInt32(FeatureCount);
}
- if (hasDistance) {
- size += pb::CodedOutputStream.ComputeInt32Size(3, Distance);
+ if (Distance != 0) {
+ output.WriteRawTag(24);
+ output.WriteInt32(Distance);
}
- if (hasElapsedTime) {
- size += pb::CodedOutputStream.ComputeInt32Size(4, ElapsedTime);
+ if (ElapsedTime != 0) {
+ output.WriteRawTag(32);
+ output.WriteInt32(ElapsedTime);
}
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- public static RouteSummary ParseFrom(pb::ByteString data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static RouteSummary ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static RouteSummary ParseFrom(byte[] data) {
- return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static RouteSummary ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static RouteSummary ParseFrom(global::System.IO.Stream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static RouteSummary ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static RouteSummary ParseDelimitedFrom(global::System.IO.Stream input) {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static RouteSummary ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static RouteSummary ParseFrom(pb::ICodedInputStream input) {
- return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static RouteSummary ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private RouteSummary MakeReadOnly() {
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(RouteSummary prototype) {
- return new Builder(prototype);
}
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder<RouteSummary, Builder> {
- protected override Builder ThisBuilder {
- get { return this; }
+ public int CalculateSize() {
+ int size = 0;
+ if (PointCount != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(PointCount);
}
- public Builder() {
- result = DefaultInstance;
- resultIsReadOnly = true;
+ if (FeatureCount != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(FeatureCount);
}
- internal Builder(RouteSummary cloneFrom) {
- result = cloneFrom;
- resultIsReadOnly = true;
+ if (Distance != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(Distance);
}
-
- private bool resultIsReadOnly;
- private RouteSummary result;
-
- private RouteSummary PrepareBuilder() {
- if (resultIsReadOnly) {
- RouteSummary original = result;
- result = new RouteSummary();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized {
- get { return result.IsInitialized; }
- }
-
- protected override RouteSummary MessageBeingBuilt {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear() {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
+ if (ElapsedTime != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(ElapsedTime);
}
+ return size;
+ }
- public override Builder Clone() {
- if (resultIsReadOnly) {
- return new Builder(result);
- } else {
- return new Builder().MergeFrom(result);
- }
+ public void MergeFrom(RouteSummary other) {
+ if (other == null) {
+ return;
}
-
- public override pbd::MessageDescriptor DescriptorForType {
- get { return global::examples.RouteSummary.Descriptor; }
+ if (other.PointCount != 0) {
+ PointCount = other.PointCount;
}
-
- public override RouteSummary DefaultInstanceForType {
- get { return global::examples.RouteSummary.DefaultInstance; }
+ if (other.FeatureCount != 0) {
+ FeatureCount = other.FeatureCount;
}
-
- public override RouteSummary BuildPartial() {
- if (resultIsReadOnly) {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
+ if (other.Distance != 0) {
+ Distance = other.Distance;
}
-
- public override Builder MergeFrom(pb::IMessage other) {
- if (other is RouteSummary) {
- return MergeFrom((RouteSummary) other);
- } else {
- base.MergeFrom(other);
- return this;
- }
+ if (other.ElapsedTime != 0) {
+ ElapsedTime = other.ElapsedTime;
}
+ }
- public override Builder MergeFrom(RouteSummary other) {
- if (other == global::examples.RouteSummary.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasPointCount) {
- PointCount = other.PointCount;
- }
- if (other.HasFeatureCount) {
- FeatureCount = other.FeatureCount;
- }
- if (other.HasDistance) {
- Distance = other.Distance;
- }
- if (other.HasElapsedTime) {
- ElapsedTime = other.ElapsedTime;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input) {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name)) {
- if(tag == 0 && field_name != null) {
- int field_ordinal = global::System.Array.BinarySearch(_routeSummaryFieldNames, field_name, global::System.StringComparer.Ordinal);
- if(field_ordinal >= 0)
- tag = _routeSummaryFieldTags[field_ordinal];
- else {
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ PointCount = input.ReadInt32();
+ break;
}
- switch (tag) {
- case 0: {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default: {
- if (pb::WireFormat.IsEndGroupTag(tag)) {
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null) {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 8: {
- result.hasPointCount = input.ReadInt32(ref result.pointCount_);
- break;
- }
- case 16: {
- result.hasFeatureCount = input.ReadInt32(ref result.featureCount_);
- break;
- }
- case 24: {
- result.hasDistance = input.ReadInt32(ref result.distance_);
- break;
- }
- case 32: {
- result.hasElapsedTime = input.ReadInt32(ref result.elapsedTime_);
- break;
- }
+ case 16: {
+ FeatureCount = input.ReadInt32();
+ break;
+ }
+ case 24: {
+ Distance = input.ReadInt32();
+ break;
+ }
+ case 32: {
+ ElapsedTime = input.ReadInt32();
+ break;
}
}
-
- if (unknownFields != null) {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasPointCount {
- get { return result.hasPointCount; }
- }
- public int PointCount {
- get { return result.PointCount; }
- set { SetPointCount(value); }
- }
- public Builder SetPointCount(int value) {
- PrepareBuilder();
- result.hasPointCount = true;
- result.pointCount_ = value;
- return this;
- }
- public Builder ClearPointCount() {
- PrepareBuilder();
- result.hasPointCount = false;
- result.pointCount_ = 0;
- return this;
- }
-
- public bool HasFeatureCount {
- get { return result.hasFeatureCount; }
- }
- public int FeatureCount {
- get { return result.FeatureCount; }
- set { SetFeatureCount(value); }
- }
- public Builder SetFeatureCount(int value) {
- PrepareBuilder();
- result.hasFeatureCount = true;
- result.featureCount_ = value;
- return this;
- }
- public Builder ClearFeatureCount() {
- PrepareBuilder();
- result.hasFeatureCount = false;
- result.featureCount_ = 0;
- return this;
- }
-
- public bool HasDistance {
- get { return result.hasDistance; }
- }
- public int Distance {
- get { return result.Distance; }
- set { SetDistance(value); }
- }
- public Builder SetDistance(int value) {
- PrepareBuilder();
- result.hasDistance = true;
- result.distance_ = value;
- return this;
- }
- public Builder ClearDistance() {
- PrepareBuilder();
- result.hasDistance = false;
- result.distance_ = 0;
- return this;
- }
-
- public bool HasElapsedTime {
- get { return result.hasElapsedTime; }
- }
- public int ElapsedTime {
- get { return result.ElapsedTime; }
- set { SetElapsedTime(value); }
- }
- public Builder SetElapsedTime(int value) {
- PrepareBuilder();
- result.hasElapsedTime = true;
- result.elapsedTime_ = value;
- return this;
- }
- public Builder ClearElapsedTime() {
- PrepareBuilder();
- result.hasElapsedTime = false;
- result.elapsedTime_ = 0;
- return this;
}
}
- static RouteSummary() {
- object.ReferenceEquals(global::examples.Proto.RouteGuide.Descriptor, null);
- }
+
}
#endregion
diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
index 8358974aac..302a783aa4 100644
--- a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
+++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@@ -14,7 +14,7 @@
<AssemblyName>RouteGuide</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
- <NuGetPackageImportStamp>214cccda</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>443bbc38</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@@ -34,25 +34,18 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Google.ProtocolBuffers.Serialization">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
- </Reference>
- <Reference Include="Grpc.Core, Version=0.6.5668.37363, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.6.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.7.0.1-beta2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
- </Reference>
<Reference Include="System.Core" />
<Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath>
@@ -71,7 +64,6 @@
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
- <None Include="protos\route_guide.proto" />
<None Include="route_guide_db.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@@ -83,14 +75,14 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs
index c4b3900dca..f2dc1c2ec0 100644
--- a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs
+++ b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs
@@ -7,93 +7,130 @@ using System.Threading;
using System.Threading.Tasks;
using Grpc.Core;
-namespace examples {
+namespace Examples {
public static class RouteGuide
{
static readonly string __ServiceName = "examples.RouteGuide";
- static readonly Marshaller<global::examples.Point> __Marshaller_Point = Marshallers.Create((arg) => arg.ToByteArray(), global::examples.Point.ParseFrom);
- static readonly Marshaller<global::examples.Feature> __Marshaller_Feature = Marshallers.Create((arg) => arg.ToByteArray(), global::examples.Feature.ParseFrom);
- static readonly Marshaller<global::examples.Rectangle> __Marshaller_Rectangle = Marshallers.Create((arg) => arg.ToByteArray(), global::examples.Rectangle.ParseFrom);
- static readonly Marshaller<global::examples.RouteSummary> __Marshaller_RouteSummary = Marshallers.Create((arg) => arg.ToByteArray(), global::examples.RouteSummary.ParseFrom);
- static readonly Marshaller<global::examples.RouteNote> __Marshaller_RouteNote = Marshallers.Create((arg) => arg.ToByteArray(), global::examples.RouteNote.ParseFrom);
+ static readonly Marshaller<global::Examples.Point> __Marshaller_Point = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Examples.Point.Parser.ParseFrom);
+ static readonly Marshaller<global::Examples.Feature> __Marshaller_Feature = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Examples.Feature.Parser.ParseFrom);
+ static readonly Marshaller<global::Examples.Rectangle> __Marshaller_Rectangle = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Examples.Rectangle.Parser.ParseFrom);
+ static readonly Marshaller<global::Examples.RouteSummary> __Marshaller_RouteSummary = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Examples.RouteSummary.Parser.ParseFrom);
+ static readonly Marshaller<global::Examples.RouteNote> __Marshaller_RouteNote = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Examples.RouteNote.Parser.ParseFrom);
- static readonly Method<global::examples.Point, global::examples.Feature> __Method_GetFeature = new Method<global::examples.Point, global::examples.Feature>(
+ static readonly Method<global::Examples.Point, global::Examples.Feature> __Method_GetFeature = new Method<global::Examples.Point, global::Examples.Feature>(
MethodType.Unary,
+ __ServiceName,
"GetFeature",
__Marshaller_Point,
__Marshaller_Feature);
- static readonly Method<global::examples.Rectangle, global::examples.Feature> __Method_ListFeatures = new Method<global::examples.Rectangle, global::examples.Feature>(
+ static readonly Method<global::Examples.Rectangle, global::Examples.Feature> __Method_ListFeatures = new Method<global::Examples.Rectangle, global::Examples.Feature>(
MethodType.ServerStreaming,
+ __ServiceName,
"ListFeatures",
__Marshaller_Rectangle,
__Marshaller_Feature);
- static readonly Method<global::examples.Point, global::examples.RouteSummary> __Method_RecordRoute = new Method<global::examples.Point, global::examples.RouteSummary>(
+ static readonly Method<global::Examples.Point, global::Examples.RouteSummary> __Method_RecordRoute = new Method<global::Examples.Point, global::Examples.RouteSummary>(
MethodType.ClientStreaming,
+ __ServiceName,
"RecordRoute",
__Marshaller_Point,
__Marshaller_RouteSummary);
- static readonly Method<global::examples.RouteNote, global::examples.RouteNote> __Method_RouteChat = new Method<global::examples.RouteNote, global::examples.RouteNote>(
+ static readonly Method<global::Examples.RouteNote, global::Examples.RouteNote> __Method_RouteChat = new Method<global::Examples.RouteNote, global::Examples.RouteNote>(
MethodType.DuplexStreaming,
+ __ServiceName,
"RouteChat",
__Marshaller_RouteNote,
__Marshaller_RouteNote);
- // client-side stub interface
+ // service descriptor
+ public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor
+ {
+ get { return global::Examples.Proto.RouteGuide.Descriptor.Services[0]; }
+ }
+
+ // client interface
public interface IRouteGuideClient
{
- global::examples.Feature GetFeature(global::examples.Point request, CancellationToken token = default(CancellationToken));
- Task<global::examples.Feature> GetFeatureAsync(global::examples.Point request, CancellationToken token = default(CancellationToken));
- AsyncServerStreamingCall<global::examples.Feature> ListFeatures(global::examples.Rectangle request, CancellationToken token = default(CancellationToken));
- AsyncClientStreamingCall<global::examples.Point, global::examples.RouteSummary> RecordRoute(CancellationToken token = default(CancellationToken));
- AsyncDuplexStreamingCall<global::examples.RouteNote, global::examples.RouteNote> RouteChat(CancellationToken token = default(CancellationToken));
+ global::Examples.Feature GetFeature(global::Examples.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ global::Examples.Feature GetFeature(global::Examples.Point request, CallOptions options);
+ AsyncUnaryCall<global::Examples.Feature> GetFeatureAsync(global::Examples.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ AsyncUnaryCall<global::Examples.Feature> GetFeatureAsync(global::Examples.Point request, CallOptions options);
+ AsyncServerStreamingCall<global::Examples.Feature> ListFeatures(global::Examples.Rectangle request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ AsyncServerStreamingCall<global::Examples.Feature> ListFeatures(global::Examples.Rectangle request, CallOptions options);
+ AsyncClientStreamingCall<global::Examples.Point, global::Examples.RouteSummary> RecordRoute(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ AsyncClientStreamingCall<global::Examples.Point, global::Examples.RouteSummary> RecordRoute(CallOptions options);
+ AsyncDuplexStreamingCall<global::Examples.RouteNote, global::Examples.RouteNote> RouteChat(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ AsyncDuplexStreamingCall<global::Examples.RouteNote, global::Examples.RouteNote> RouteChat(CallOptions options);
}
// server-side interface
public interface IRouteGuide
{
- Task<global::examples.Feature> GetFeature(ServerCallContext context, global::examples.Point request);
- Task ListFeatures(ServerCallContext context, global::examples.Rectangle request, IServerStreamWriter<global::examples.Feature> responseStream);
- Task<global::examples.RouteSummary> RecordRoute(ServerCallContext context, IAsyncStreamReader<global::examples.Point> requestStream);
- Task RouteChat(ServerCallContext context, IAsyncStreamReader<global::examples.RouteNote> requestStream, IServerStreamWriter<global::examples.RouteNote> responseStream);
+ Task<global::Examples.Feature> GetFeature(global::Examples.Point request, ServerCallContext context);
+ Task ListFeatures(global::Examples.Rectangle request, IServerStreamWriter<global::Examples.Feature> responseStream, ServerCallContext context);
+ Task<global::Examples.RouteSummary> RecordRoute(IAsyncStreamReader<global::Examples.Point> requestStream, ServerCallContext context);
+ Task RouteChat(IAsyncStreamReader<global::Examples.RouteNote> requestStream, IServerStreamWriter<global::Examples.RouteNote> responseStream, ServerCallContext context);
}
// client stub
- public class RouteGuideClient : AbstractStub<RouteGuideClient, StubConfiguration>, IRouteGuideClient
+ public class RouteGuideClient : ClientBase, IRouteGuideClient
{
- public RouteGuideClient(Channel channel) : this(channel, StubConfiguration.Default)
+ public RouteGuideClient(Channel channel) : base(channel)
+ {
+ }
+ public global::Examples.Feature GetFeature(global::Examples.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var call = CreateCall(__Method_GetFeature, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.BlockingUnaryCall(call, request);
+ }
+ public global::Examples.Feature GetFeature(global::Examples.Point request, CallOptions options)
{
+ var call = CreateCall(__Method_GetFeature, options);
+ return Calls.BlockingUnaryCall(call, request);
}
- public RouteGuideClient(Channel channel, StubConfiguration config) : base(channel, config)
+ public AsyncUnaryCall<global::Examples.Feature> GetFeatureAsync(global::Examples.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
+ var call = CreateCall(__Method_GetFeature, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.AsyncUnaryCall(call, request);
}
- public global::examples.Feature GetFeature(global::examples.Point request, CancellationToken token = default(CancellationToken))
+ public AsyncUnaryCall<global::Examples.Feature> GetFeatureAsync(global::Examples.Point request, CallOptions options)
{
- var call = CreateCall(__ServiceName, __Method_GetFeature);
- return Calls.BlockingUnaryCall(call, request, token);
+ var call = CreateCall(__Method_GetFeature, options);
+ return Calls.AsyncUnaryCall(call, request);
}
- public Task<global::examples.Feature> GetFeatureAsync(global::examples.Point request, CancellationToken token = default(CancellationToken))
+ public AsyncServerStreamingCall<global::Examples.Feature> ListFeatures(global::Examples.Rectangle request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
- var call = CreateCall(__ServiceName, __Method_GetFeature);
- return Calls.AsyncUnaryCall(call, request, token);
+ var call = CreateCall(__Method_ListFeatures, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.AsyncServerStreamingCall(call, request);
}
- public AsyncServerStreamingCall<global::examples.Feature> ListFeatures(global::examples.Rectangle request, CancellationToken token = default(CancellationToken))
+ public AsyncServerStreamingCall<global::Examples.Feature> ListFeatures(global::Examples.Rectangle request, CallOptions options)
{
- var call = CreateCall(__ServiceName, __Method_ListFeatures);
- return Calls.AsyncServerStreamingCall(call, request, token);
+ var call = CreateCall(__Method_ListFeatures, options);
+ return Calls.AsyncServerStreamingCall(call, request);
}
- public AsyncClientStreamingCall<global::examples.Point, global::examples.RouteSummary> RecordRoute(CancellationToken token = default(CancellationToken))
+ public AsyncClientStreamingCall<global::Examples.Point, global::Examples.RouteSummary> RecordRoute(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
- var call = CreateCall(__ServiceName, __Method_RecordRoute);
- return Calls.AsyncClientStreamingCall(call, token);
+ var call = CreateCall(__Method_RecordRoute, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.AsyncClientStreamingCall(call);
}
- public AsyncDuplexStreamingCall<global::examples.RouteNote, global::examples.RouteNote> RouteChat(CancellationToken token = default(CancellationToken))
+ public AsyncClientStreamingCall<global::Examples.Point, global::Examples.RouteSummary> RecordRoute(CallOptions options)
{
- var call = CreateCall(__ServiceName, __Method_RouteChat);
- return Calls.AsyncDuplexStreamingCall(call, token);
+ var call = CreateCall(__Method_RecordRoute, options);
+ return Calls.AsyncClientStreamingCall(call);
+ }
+ public AsyncDuplexStreamingCall<global::Examples.RouteNote, global::Examples.RouteNote> RouteChat(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var call = CreateCall(__Method_RouteChat, new CallOptions(headers, deadline, cancellationToken));
+ return Calls.AsyncDuplexStreamingCall(call);
+ }
+ public AsyncDuplexStreamingCall<global::Examples.RouteNote, global::Examples.RouteNote> RouteChat(CallOptions options)
+ {
+ var call = CreateCall(__Method_RouteChat, options);
+ return Calls.AsyncDuplexStreamingCall(call);
}
}
@@ -107,17 +144,12 @@ namespace examples {
.AddMethod(__Method_RouteChat, serviceImpl.RouteChat).Build();
}
- // creates a new client stub
- public static IRouteGuideClient NewStub(Channel channel)
+ // creates a new client
+ public static RouteGuideClient NewClient(Channel channel)
{
return new RouteGuideClient(channel);
}
- // creates a new client stub
- public static IRouteGuideClient NewStub(Channel channel, StubConfiguration config)
- {
- return new RouteGuideClient(channel, config);
- }
}
}
#endregion
diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuideUtil.cs b/examples/csharp/route_guide/RouteGuide/RouteGuideUtil.cs
index 6fb8b1e28a..21a0be43d2 100644
--- a/examples/csharp/route_guide/RouteGuide/RouteGuideUtil.cs
+++ b/examples/csharp/route_guide/RouteGuide/RouteGuideUtil.cs
@@ -7,8 +7,11 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace examples
+namespace Examples
{
+ /// <summary>
+ /// Utility methods for the route guide example.
+ /// </summary>
public static class RouteGuideUtil
{
public const string DefaultFeaturesFile = "route_guide_db.json";
@@ -18,22 +21,64 @@ namespace examples
/// <summary>
/// Indicates whether the given feature exists (i.e. has a valid name).
/// </summary>
- public static bool Exists(Feature feature)
+ public static bool Exists(this Feature feature)
{
return feature != null && (feature.Name.Length != 0);
}
- public static double GetLatitude(Point point)
+ public static double GetLatitude(this Point point)
{
return point.Latitude / CoordFactor;
}
- public static double GetLongitude(Point point)
+ public static double GetLongitude(this Point point)
{
return point.Longitude / CoordFactor;
}
/// <summary>
+ /// Calculate the distance between two points using the "haversine" formula.
+ /// This code was taken from http://www.movable-type.co.uk/scripts/latlong.html.
+ /// </summary>
+ /// <param name="start">the starting point</param>
+ /// <param name="end">the end point</param>
+ /// <returns>the distance between the points in meters</returns>
+ public static double GetDistance(this Point start, Point end)
+ {
+ double lat1 = start.GetLatitude();
+ double lat2 = end.GetLatitude();
+ double lon1 = start.GetLongitude();
+ double lon2 = end.GetLongitude();
+ int r = 6371000; // metres
+ double phi1 = ToRadians(lat1);
+ double phi2 = ToRadians(lat2);
+ double deltaPhi = ToRadians(lat2 - lat1);
+ double deltaLambda = ToRadians(lon2 - lon1);
+
+ double a = Math.Sin(deltaPhi / 2) * Math.Sin(deltaPhi / 2) + Math.Cos(phi1) * Math.Cos(phi2) * Math.Sin(deltaLambda / 2) * Math.Sin(deltaLambda / 2);
+ double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
+
+ return r * c;
+ }
+
+ /// <summary>
+ /// Returns <c>true</c> if rectangular area contains given point.
+ /// </summary>
+ public static bool Contains(this Rectangle rectangle, Point point)
+ {
+ int left = Math.Min(rectangle.Lo.Longitude, rectangle.Hi.Longitude);
+ int right = Math.Max(rectangle.Lo.Longitude, rectangle.Hi.Longitude);
+ int top = Math.Max(rectangle.Lo.Latitude, rectangle.Hi.Latitude);
+ int bottom = Math.Min(rectangle.Lo.Latitude, rectangle.Hi.Latitude);
+ return (point.Longitude >= left && point.Longitude <= right && point.Latitude >= bottom && point.Latitude <= top);
+ }
+
+ private static double ToRadians(double val)
+ {
+ return (Math.PI / 180) * val;
+ }
+
+ /// <summary>
/// Parses features from a JSON file.
/// </summary>
public static List<Feature> ParseFeatures(string filename)
@@ -41,13 +86,13 @@ namespace examples
var features = new List<Feature>();
var jsonFeatures = JsonConvert.DeserializeObject<List<JsonFeature>>(File.ReadAllText(filename));
-
foreach(var jsonFeature in jsonFeatures)
{
- features.Add(Feature.CreateBuilder().SetName(jsonFeature.name).SetLocation(
- Point.CreateBuilder()
- .SetLongitude(jsonFeature.location.longitude)
- .SetLatitude(jsonFeature.location.latitude).Build()).Build());
+ features.Add(new Feature
+ {
+ Name = jsonFeature.name,
+ Location = new Point { Longitude = jsonFeature.location.longitude, Latitude = jsonFeature.location.latitude}
+ });
}
return features;
}
diff --git a/examples/csharp/route_guide/RouteGuide/packages.config b/examples/csharp/route_guide/RouteGuide/packages.config
index 79abe0aa65..8cd2ee758d 100644
--- a/examples/csharp/route_guide/RouteGuide/packages.config
+++ b/examples/csharp/route_guide/RouteGuide/packages.config
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net45" />
- <package id="Grpc" version="0.6.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.6.0" targetFramework="net45" />
- <package id="grpc.dependencies.openssl.redist" version="1.0.2.2" targetFramework="net45" />
+ <package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
+ <package id="Grpc" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.10.0" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1-beta2" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/RouteGuide/protos/route_guide.proto b/examples/csharp/route_guide/RouteGuide/protos/route_guide.proto
deleted file mode 100644
index f4110b5515..0000000000
--- a/examples/csharp/route_guide/RouteGuide/protos/route_guide.proto
+++ /dev/null
@@ -1,123 +0,0 @@
-// 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.
-
-// TODO(jtattermusch): as of now, C# protobufs don't officially support
-// proto3.
-syntax = "proto2";
-
-package examples;
-
-// Interface exported by the server.
-service RouteGuide {
- // 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.
- rpc GetFeature(Point) returns (Feature) {}
-
- // 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.
- rpc ListFeatures(Rectangle) returns (stream Feature) {}
-
- // A client-to-server streaming RPC.
- //
- // Accepts a stream of Points on a route being traversed, returning a
- // RouteSummary when traversal is completed.
- rpc RecordRoute(stream Point) returns (RouteSummary) {}
-
- // 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).
- rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
-}
-
-// Points are represented as latitude-longitude pairs in the E7 representation
-// (degrees multiplied by 10**7 and rounded to the nearest integer).
-// Latitudes should be in the range +/- 90 degrees and longitude should be in
-// the range +/- 180 degrees (inclusive).
-message Point {
- optional int32 latitude = 1;
- optional int32 longitude = 2;
-}
-
-// A latitude-longitude rectangle, represented as two diagonally opposite
-// points "lo" and "hi".
-message Rectangle {
- // One corner of the rectangle.
- optional Point lo = 1;
-
- // The other corner of the rectangle.
- optional Point hi = 2;
-}
-
-// A feature names something at a given point.
-//
-// If a feature could not be named, the name is empty.
-message Feature {
- // The name of the feature.
- optional string name = 1;
-
- // The point where the feature is detected.
- optional Point location = 2;
-}
-
-// A RouteNote is a message sent while at a given point.
-message RouteNote {
- // The location from which the message is sent.
- optional Point location = 1;
-
- // The message to be sent.
- optional string message = 2;
-}
-
-// A RouteSummary is received in response to a RecordRoute rpc.
-//
-// It contains the number of individual points received, the number of
-// detected features, and the total distance covered as the cumulative sum of
-// the distance between each point.
-message RouteSummary {
- // The number of points received.
- optional int32 point_count = 1;
-
- // The number of known features passed while traversing the route.
- optional int32 feature_count = 2;
-
- // The distance covered in metres.
- optional int32 distance = 3;
-
- // The duration of the traversal in seconds.
- optional int32 elapsed_time = 4;
-}
diff --git a/examples/csharp/route_guide/RouteGuideClient/Program.cs b/examples/csharp/route_guide/RouteGuideClient/Program.cs
index 0352c78020..4ddb526585 100644
--- a/examples/csharp/route_guide/RouteGuideClient/Program.cs
+++ b/examples/csharp/route_guide/RouteGuideClient/Program.cs
@@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace examples
+namespace Examples
{
class Program
{
@@ -30,27 +30,24 @@ namespace examples
{
Log("*** GetFeature: lat={0} lon={1}", lat, lon);
- Point request = Point.CreateBuilder().SetLatitude(lat).SetLongitude(lon).Build();
+ Point request = new Point { Latitude = lat, Longitude = lon };
Feature feature = client.GetFeature(request);
- if (RouteGuideUtil.Exists(feature))
+ if (feature.Exists())
{
Log("Found feature called \"{0}\" at {1}, {2}",
- feature.Name,
- RouteGuideUtil.GetLatitude(feature.Location),
- RouteGuideUtil.GetLongitude(feature.Location));
+ feature.Name, feature.Location.GetLatitude(), feature.Location.GetLongitude());
}
else
{
Log("Found no feature at {0}, {1}",
- RouteGuideUtil.GetLatitude(feature.Location),
- RouteGuideUtil.GetLongitude(feature.Location));
+ feature.Location.GetLatitude(), feature.Location.GetLongitude());
}
}
catch (RpcException e)
{
Log("RPC failed " + e);
- throw e;
+ throw;
}
}
@@ -65,18 +62,20 @@ namespace examples
Log("*** ListFeatures: lowLat={0} lowLon={1} hiLat={2} hiLon={3}", lowLat, lowLon, hiLat,
hiLon);
- Rectangle request =
- Rectangle.CreateBuilder()
- .SetLo(Point.CreateBuilder().SetLatitude(lowLat).SetLongitude(lowLon).Build())
- .SetHi(Point.CreateBuilder().SetLatitude(hiLat).SetLongitude(hiLon).Build()).Build();
+ Rectangle request = new Rectangle
+ {
+ Lo = new Point { Latitude = lowLat, Longitude = lowLon },
+ Hi = new Point { Latitude = hiLat, Longitude = hiLon }
+ };
using (var call = client.ListFeatures(request))
{
+ var responseStream = call.ResponseStream;
StringBuilder responseLog = new StringBuilder("Result: ");
- while (await call.ResponseStream.MoveNext())
+ while (await responseStream.MoveNext())
{
- Feature feature = call.ResponseStream.Current;
+ Feature feature = responseStream.Current;
responseLog.Append(feature.ToString());
}
Log(responseLog.ToString());
@@ -85,7 +84,7 @@ namespace examples
catch (RpcException e)
{
Log("RPC failed " + e);
- throw e;
+ throw;
}
}
@@ -107,8 +106,7 @@ namespace examples
{
int index = rand.Next(features.Count);
Point point = features[index].Location;
- Log("Visiting point {0}, {1}", RouteGuideUtil.GetLatitude(point),
- RouteGuideUtil.GetLongitude(point));
+ Log("Visiting point {0}, {1}", point.GetLatitude(), point.GetLongitude());
await call.RequestStream.WriteAsync(point);
@@ -117,7 +115,7 @@ namespace examples
}
await call.RequestStream.CompleteAsync();
- RouteSummary summary = await call.Result;
+ RouteSummary summary = await call.ResponseAsync;
Log("Finished trip with {0} points. Passed {1} features. "
+ "Travelled {2} meters. It took {3} seconds.", summary.PointCount,
summary.FeatureCount, summary.Distance, summary.ElapsedTime);
@@ -128,7 +126,7 @@ namespace examples
catch (RpcException e)
{
Log("RPC failed", e);
- throw e;
+ throw;
}
}
@@ -141,8 +139,13 @@ namespace examples
try
{
Log("*** RouteChat");
- var requests =
- new List<RouteNote> { NewNote("First message", 0, 0), NewNote("Second message", 0, 1), NewNote("Third message", 1, 0), NewNote("Fourth message", 1, 1) };
+ var requests = new List<RouteNote>
+ {
+ NewNote("First message", 0, 0),
+ NewNote("Second message", 0, 1),
+ NewNote("Third message", 1, 0),
+ NewNote("Fourth message", 0, 0)
+ };
using (var call = client.RouteChat())
{
@@ -172,7 +175,7 @@ namespace examples
catch (RpcException e)
{
Log("RPC failed", e);
- throw e;
+ throw;
}
}
@@ -188,36 +191,37 @@ namespace examples
private RouteNote NewNote(string message, int lat, int lon)
{
- return RouteNote.CreateBuilder().SetMessage(message).SetLocation(
- Point.CreateBuilder().SetLatitude(lat).SetLongitude(lat).Build()).Build();
+ return new RouteNote
+ {
+ Message = message,
+ Location = new Point { Latitude = lat, Longitude = lon }
+ };
}
}
static void Main(string[] args)
{
- GrpcEnvironment.Initialize();
+ var channel = new Channel("127.0.0.1:50052", Credentials.Insecure);
+ var client = new RouteGuideClient(RouteGuide.NewClient(channel));
- using (Channel channel = new Channel("127.0.0.1:50052"))
- {
- var client = new RouteGuideClient(RouteGuide.NewStub(channel));
-
- // Looking for a valid feature
- client.GetFeature(409146138, -746188906);
+ // Looking for a valid feature
+ client.GetFeature(409146138, -746188906);
- // Feature missing.
- client.GetFeature(0, 0);
+ // Feature missing.
+ client.GetFeature(0, 0);
- // Looking for features between 40, -75 and 42, -73.
- client.ListFeatures(400000000, -750000000, 420000000, -730000000).Wait();
+ // Looking for features between 40, -75 and 42, -73.
+ client.ListFeatures(400000000, -750000000, 420000000, -730000000).Wait();
- // Record a few randomly selected points from the features file.
- client.RecordRoute(RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile), 10).Wait();
+ // Record a few randomly selected points from the features file.
+ client.RecordRoute(RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile), 10).Wait();
- // Send and receive some notes.
- client.RouteChat().Wait();
- }
+ // Send and receive some notes.
+ client.RouteChat().Wait();
- GrpcEnvironment.Shutdown();
+ channel.ShutdownAsync().Wait();
+ Console.WriteLine("Press any key to exit...");
+ Console.ReadKey();
}
}
}
diff --git a/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj b/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
index 78034a9145..cf9e567f5e 100644
--- a/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
+++ b/examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@@ -14,7 +14,7 @@
<AssemblyName>RouteGuideClient</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
- <NuGetPackageImportStamp>794416d0</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>77622de6</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -36,21 +36,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Google.ProtocolBuffers.Serialization">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
- </Reference>
- <Reference Include="Grpc.Core, Version=0.6.5668.37363, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.6.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
- </Reference>
<Reference Include="System.Core" />
<Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath>
@@ -82,14 +75,14 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
diff --git a/examples/csharp/route_guide/RouteGuideClient/packages.config b/examples/csharp/route_guide/RouteGuideClient/packages.config
index 5922553bc3..1273624cbd 100644
--- a/examples/csharp/route_guide/RouteGuideClient/packages.config
+++ b/examples/csharp/route_guide/RouteGuideClient/packages.config
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net45" />
- <package id="Grpc" version="0.6.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.6.0" targetFramework="net45" />
- <package id="grpc.dependencies.openssl.redist" version="1.0.2.2" targetFramework="net45" />
+ <package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
+ <package id="Grpc" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.10.0" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/RouteGuideServer/Program.cs b/examples/csharp/route_guide/RouteGuideServer/Program.cs
index e00b4d6723..0a4d73f391 100644
--- a/examples/csharp/route_guide/RouteGuideServer/Program.cs
+++ b/examples/csharp/route_guide/RouteGuideServer/Program.cs
@@ -5,26 +5,28 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace examples
+namespace Examples
{
class Program
{
static void Main(string[] args)
{
+ const int Port = 50052;
+
var features = RouteGuideUtil.ParseFeatures(RouteGuideUtil.DefaultFeaturesFile);
- GrpcEnvironment.Initialize();
- Server server = new Server();
- server.AddServiceDefinition(RouteGuide.BindService(new RouteGuideImpl(features)));
- int port = server.AddListeningPort("localhost", 50052);
+ Server server = new Server
+ {
+ Services = { RouteGuide.BindService(new RouteGuideImpl(features)) },
+ Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) }
+ };
server.Start();
- Console.WriteLine("RouteGuide server listening on port " + port);
+ Console.WriteLine("RouteGuide server listening on port " + Port);
Console.WriteLine("Press any key to stop the server...");
Console.ReadKey();
server.ShutdownAsync().Wait();
- GrpcEnvironment.Shutdown();
}
}
}
diff --git a/examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs b/examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs
index 0bdf386fc3..fbe0f4471c 100644
--- a/examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs
+++ b/examples/csharp/route_guide/RouteGuideServer/RouteGuideImpl.cs
@@ -6,7 +6,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-namespace examples
+using Grpc.Core.Utils;
+
+namespace Examples
{
/// <summary>
/// Example implementation of RouteGuide server.
@@ -14,8 +16,8 @@ namespace examples
public class RouteGuideImpl : RouteGuide.IRouteGuide
{
readonly List<Feature> features;
- private readonly ConcurrentDictionary<Point, List<RouteNote>> routeNotes =
- new ConcurrentDictionary<Point, List<RouteNote>>();
+ readonly object myLock = new object();
+ readonly Dictionary<Point, List<RouteNote>> routeNotes = new Dictionary<Point, List<RouteNote>>();
public RouteGuideImpl(List<Feature> features)
{
@@ -26,7 +28,7 @@ namespace examples
/// Gets the feature at the requested point. If no feature at that location
/// exists, an unnammed feature is returned at the provided location.
/// </summary>
- public Task<Feature> GetFeature(Grpc.Core.ServerCallContext context, Point request)
+ public Task<Feature> GetFeature(Point request, Grpc.Core.ServerCallContext context)
{
return Task.FromResult(CheckFeature(request));
}
@@ -34,26 +36,12 @@ namespace examples
/// <summary>
/// Gets all features contained within the given bounding rectangle.
/// </summary>
- public async Task ListFeatures(Grpc.Core.ServerCallContext context, Rectangle request, Grpc.Core.IServerStreamWriter<Feature> responseStream)
+ public async Task ListFeatures(Rectangle request, Grpc.Core.IServerStreamWriter<Feature> responseStream, Grpc.Core.ServerCallContext context)
{
- int left = Math.Min(request.Lo.Longitude, request.Hi.Longitude);
- int right = Math.Max(request.Lo.Longitude, request.Hi.Longitude);
- int top = Math.Max(request.Lo.Latitude, request.Hi.Latitude);
- int bottom = Math.Min(request.Lo.Latitude, request.Hi.Latitude);
-
- foreach (var feature in features)
+ var responses = features.FindAll( (feature) => feature.Exists() && request.Contains(feature.Location) );
+ foreach (var response in responses)
{
- if (!RouteGuideUtil.Exists(feature))
- {
- continue;
- }
-
- int lat = feature.Location.Latitude;
- int lon = feature.Location.Longitude;
- if (lon >= left && lon <= right && lat >= bottom && lat <= top)
- {
- await responseStream.WriteAsync(feature);
- }
+ await responseStream.WriteAsync(response);
}
}
@@ -61,7 +49,7 @@ namespace examples
/// Gets a stream of points, and responds with statistics about the "trip": number of points,
/// number of known features visited, total distance traveled, and total time spent.
/// </summary>
- public async Task<RouteSummary> RecordRoute(Grpc.Core.ServerCallContext context, Grpc.Core.IAsyncStreamReader<Point> requestStream)
+ public async Task<RouteSummary> RecordRoute(Grpc.Core.IAsyncStreamReader<Point> requestStream, Grpc.Core.ServerCallContext context)
{
int pointCount = 0;
int featureCount = 0;
@@ -74,61 +62,61 @@ namespace examples
{
var point = requestStream.Current;
pointCount++;
- if (RouteGuideUtil.Exists(CheckFeature(point)))
+ if (CheckFeature(point).Exists())
{
featureCount++;
}
if (previous != null)
{
- distance += (int) CalcDistance(previous, point);
+ distance += (int) previous.GetDistance(point);
}
previous = point;
}
stopwatch.Stop();
- return RouteSummary.CreateBuilder().SetPointCount(pointCount)
- .SetFeatureCount(featureCount).SetDistance(distance)
- .SetElapsedTime((int) (stopwatch.ElapsedMilliseconds / 1000)).Build();
+
+ return new RouteSummary
+ {
+ PointCount = pointCount,
+ FeatureCount = featureCount,
+ Distance = distance,
+ ElapsedTime = (int)(stopwatch.ElapsedMilliseconds / 1000)
+ };
}
/// <summary>
/// Receives a stream of message/location pairs, and responds with a stream of all previous
/// messages at each of those locations.
/// </summary>
- public async Task RouteChat(Grpc.Core.ServerCallContext context, Grpc.Core.IAsyncStreamReader<RouteNote> requestStream, Grpc.Core.IServerStreamWriter<RouteNote> responseStream)
+ public async Task RouteChat(Grpc.Core.IAsyncStreamReader<RouteNote> requestStream, Grpc.Core.IServerStreamWriter<RouteNote> responseStream, Grpc.Core.ServerCallContext context)
{
while (await requestStream.MoveNext())
{
var note = requestStream.Current;
- List<RouteNote> notes = GetOrCreateNotes(note.Location);
-
- List<RouteNote> prevNotes;
- lock (notes)
- {
- prevNotes = new List<RouteNote>(notes);
- }
-
+ List<RouteNote> prevNotes = AddNoteForLocation(note.Location, note);
foreach (var prevNote in prevNotes)
{
await responseStream.WriteAsync(prevNote);
- }
-
- lock (notes)
- {
- notes.Add(note);
}
}
}
-
/// <summary>
- /// Get the notes list for the given location. If missing, create it.
+ /// Adds a note for location and returns a list of pre-existing notes for that location (not containing the newly added note).
/// </summary>
- private List<RouteNote> GetOrCreateNotes(Point location)
+ private List<RouteNote> AddNoteForLocation(Point location, RouteNote note)
{
- List<RouteNote> notes = new List<RouteNote>();
- routeNotes.TryAdd(location, notes);
- return routeNotes[location];
+ lock (myLock)
+ {
+ List<RouteNote> notes;
+ if (!routeNotes.TryGetValue(location, out notes)) {
+ notes = new List<RouteNote>();
+ routeNotes.Add(location, notes);
+ }
+ var preexistingNotes = new List<RouteNote>(notes);
+ notes.Add(note);
+ return preexistingNotes;
+ }
}
/// <summary>
@@ -138,47 +126,13 @@ namespace examples
/// <returns>The feature object at the point Note that an empty name indicates no feature.</returns>
private Feature CheckFeature(Point location)
{
- foreach (var feature in features)
+ var result = features.FirstOrDefault((feature) => feature.Location.Equals(location));
+ if (result == null)
{
- if (feature.Location.Latitude == location.Latitude
- && feature.Location.Longitude == location.Longitude)
- {
- return feature;
- }
+ // No feature was found, return an unnamed feature.
+ return new Feature { Name = "", Location = location };
}
-
- // No feature was found, return an unnamed feature.
- return Feature.CreateBuilder().SetName("").SetLocation(location).Build();
- }
-
- /// <summary>
- /// Calculate the distance between two points using the "haversine" formula.
- /// This code was taken from http://www.movable-type.co.uk/scripts/latlong.html.
- /// </summary>
- /// <param name="start">the starting point</param>
- /// <param name="end">the end point</param>
- /// <returns>the distance between the points in meters</returns>
- private static double CalcDistance(Point start, Point end)
- {
- double lat1 = RouteGuideUtil.GetLatitude(start);
- double lat2 = RouteGuideUtil.GetLatitude(end);
- double lon1 = RouteGuideUtil.GetLongitude(start);
- double lon2 = RouteGuideUtil.GetLongitude(end);
- int r = 6371000; // metres
- double φ1 = ToRadians(lat1);
- double φ2 = ToRadians(lat2);
- double Δφ = ToRadians(lat2 - lat1);
- double Δλ = ToRadians(lon2 - lon1);
-
- double a = Math.Sin(Δφ / 2) * Math.Sin(Δφ / 2) + Math.Cos(φ1) * Math.Cos(φ2) * Math.Sin(Δλ / 2) * Math.Sin(Δλ / 2);
- double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
-
- return r * c;
- }
-
- private static double ToRadians(double val)
- {
- return (Math.PI / 180) * val;
+ return result;
}
}
}
diff --git a/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj b/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
index 9ac1cfbf4d..55e1331c46 100644
--- a/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
+++ b/examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" />
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
@@ -14,7 +14,7 @@
<AssemblyName>RouteGuideServer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
- <NuGetPackageImportStamp>74781d8b</NuGetPackageImportStamp>
+ <NuGetPackageImportStamp>568005e2</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -36,21 +36,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.ProtocolBuffers">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath>
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.0.0-alpha4\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Google.ProtocolBuffers.Serialization">
- <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
- </Reference>
- <Reference Include="Grpc.Core, Version=0.6.5668.37363, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="Grpc.Core, Version=0.7.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Grpc.Core.0.6.0\lib\net45\Grpc.Core.dll</HintPath>
+ <HintPath>..\packages\Grpc.Core.0.7.0\lib\net45\Grpc.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.Collections.Immutable, Version=1.1.36.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\System.Collections.Immutable.1.1.36\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
- </Reference>
<Reference Include="System.Core" />
<Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.3\lib\net45\System.Interactive.Async.dll</HintPath>
@@ -83,14 +76,14 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.props'))" />
<Error Condition="!Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
- <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
- <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.props'))" />
+ <Error Condition="!Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets'))" />
</Target>
<Import Project="..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets" Condition="Exists('..\packages\grpc.dependencies.zlib.redist.1.2.8.9\build\portable-net45\grpc.dependencies.zlib.redist.targets')" />
- <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.2\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
- <Import Project="..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.10.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
+ <Import Project="..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets" Condition="Exists('..\packages\grpc.dependencies.openssl.redist.1.0.2.3\build\portable-net45\grpc.dependencies.openssl.redist.targets')" />
+ <Import Project="..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets" Condition="Exists('..\packages\grpc.native.csharp_ext.0.11.0\build\portable-net45\grpc.native.csharp_ext.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
diff --git a/examples/csharp/route_guide/RouteGuideServer/packages.config b/examples/csharp/route_guide/RouteGuideServer/packages.config
index 5922553bc3..1273624cbd 100644
--- a/examples/csharp/route_guide/RouteGuideServer/packages.config
+++ b/examples/csharp/route_guide/RouteGuideServer/packages.config
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Google.ProtocolBuffers" version="2.4.1.555" targetFramework="net45" />
- <package id="Grpc" version="0.6.0" targetFramework="net45" />
- <package id="Grpc.Core" version="0.6.0" targetFramework="net45" />
- <package id="grpc.dependencies.openssl.redist" version="1.0.2.2" targetFramework="net45" />
+ <package id="Google.Protobuf" version="3.0.0-alpha4" targetFramework="net45" />
+ <package id="Grpc" version="0.7.0" targetFramework="net45" />
+ <package id="Grpc.Core" version="0.7.0" targetFramework="net45" />
+ <package id="grpc.dependencies.openssl.redist" version="1.0.2.3" targetFramework="net45" />
<package id="grpc.dependencies.zlib.redist" version="1.2.8.9" targetFramework="net45" />
- <package id="grpc.native.csharp_ext" version="0.10.0" targetFramework="net45" />
+ <package id="grpc.native.csharp_ext" version="0.11.0" targetFramework="net45" />
<package id="Ix-Async" version="1.2.3" targetFramework="net45" />
- <package id="System.Collections.Immutable" version="1.1.36" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/examples/csharp/route_guide/generate_protos.bat b/examples/csharp/route_guide/generate_protos.bat
new file mode 100644
index 0000000000..fb0dc5516b
--- /dev/null
+++ b/examples/csharp/route_guide/generate_protos.bat
@@ -0,0 +1,10 @@
+@rem Generate the C# code for .proto files
+
+setlocal
+
+@rem enter this directory
+cd /d %~dp0
+
+packages\Google.Protobuf.3.0.0-alpha4\tools\protoc.exe -I../../protos --csharp_out RouteGuide ../../protos/route_guide.proto --grpc_out RouteGuide --plugin=protoc-gen-grpc=packages\Grpc.Tools.0.7.0\tools\grpc_csharp_plugin.exe
+
+endlocal \ No newline at end of file
diff --git a/examples/node/route_guide/README.md b/examples/node/route_guide/README.md
index 1dbaac9f9f..1048606509 100644
--- a/examples/node/route_guide/README.md
+++ b/examples/node/route_guide/README.md
@@ -96,10 +96,10 @@ To load a `.proto` file, simply `require` the gRPC library, then use its `load()
var grpc = require('grpc');
var protoDescriptor = grpc.load(__dirname + '/route_guide.proto');
// The protoDescriptor object has the full package hierarchy
-var example = protoDescriptor.examples;
+var example = protoDescriptor.routeguide;
```
-Once you've done this, the stub constructor is in the `examples` namespace (`protoDescriptor.examples.RouteGuide`) and the service descriptor (which is used to create a server) is a property of the stub (`protoDescriptor.examples.RouteGuide.service`);
+Once you've done this, the stub constructor is in the `routeguide` namespace (`protoDescriptor.routeguide.RouteGuide`) and the service descriptor (which is used to create a server) is a property of the stub (`protoDescriptor.routeguide.RouteGuide.service`);
<a name="server"></a>
## Creating the server
@@ -117,7 +117,7 @@ You can find our example `RouteGuide` server in [route_guide_server.js](route_gu
As you can see, our server has a `Server` constructor generated from the `RouteGuide.service` descriptor object
```node
-var Server = grpc.buildServer([examples.RouteGuide.service]);
+var Server = grpc.buildServer([routeguide.RouteGuide.service]);
```
In this case we're implementing the *asynchronous* version of `RouteGuide`, which provides our default gRPC server behaviour.
@@ -219,18 +219,18 @@ Once we've implemented all our methods, we also need to start up a gRPC server s
```node
function getServer() {
- return new Server({
- 'examples.RouteGuide' : {
- getFeature: getFeature,
- listFeatures: listFeatures,
- recordRoute: recordRoute,
- routeChat: routeChat
- }
+ var server = new grpc.Server();
+ server.addProtoService(routeguide.RouteGuide.service, {
+ getFeature: getFeature,
+ listFeatures: listFeatures,
+ recordRoute: recordRoute,
+ routeChat: routeChat
});
+ return server;
}
var routeServer = getServer();
-routeServer.bind('0.0.0.0:50051');
-routeServer.listen();
+routeServer.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());
+routeServer.start();
```
As you can see, we build and start our server with the following steps:
@@ -251,7 +251,8 @@ In this section, we'll look at creating a Node.js client for our `RouteGuide` se
To call service methods, we first need to create a *stub*. To do this, we just need to call the RouteGuide stub constructor, specifying the server address and port.
```node
-new example.RouteGuide('localhost:50051');
+var client = new routeguide.RouteGuide('localhost:50051',
+ grpc.Credentials.createInsecure());
```
### Calling service methods
diff --git a/examples/node/route_guide/route_guide.proto b/examples/node/route_guide/route_guide.proto
index 442112823e..38daa933cd 100644
--- a/examples/node/route_guide/route_guide.proto
+++ b/examples/node/route_guide/route_guide.proto
@@ -29,9 +29,9 @@
syntax = "proto3";
-option java_package = "io.grpc.examples";
+option java_package = "io.grpc.routeguide";
-package examples;
+package routeguide;
// Interface exported by the server.
service RouteGuide {
diff --git a/examples/node/route_guide/route_guide_client.js b/examples/node/route_guide/route_guide_client.js
index 3550d797d9..1da6c69025 100644
--- a/examples/node/route_guide/route_guide_client.js
+++ b/examples/node/route_guide/route_guide_client.js
@@ -33,9 +33,9 @@ var parseArgs = require('minimist');
var path = require('path');
var _ = require('underscore');
var grpc = require('grpc');
-var examples = grpc.load(__dirname + '/route_guide.proto').examples;
-var client = new examples.RouteGuide('localhost:50051',
- grpc.Credentials.createInsecure());
+var routeguide = grpc.load(__dirname + '/route_guide.proto').routeguide;
+var client = new routeguide.RouteGuide('localhost:50051',
+ grpc.Credentials.createInsecure());
var COORD_FACTOR = 1e7;
diff --git a/examples/node/route_guide/route_guide_server.js b/examples/node/route_guide/route_guide_server.js
index 38e1f94a92..faae3087fd 100644
--- a/examples/node/route_guide/route_guide_server.js
+++ b/examples/node/route_guide/route_guide_server.js
@@ -32,7 +32,7 @@ var parseArgs = require('minimist');
var path = require('path');
var _ = require('underscore');
var grpc = require('grpc');
-var examples = grpc.load(__dirname + '/route_guide.proto').examples;
+var routeguide = grpc.load(__dirname + '/route_guide.proto').routeguide;
var COORD_FACTOR = 1e7;
@@ -221,7 +221,7 @@ function routeChat(call) {
*/
function getServer() {
var server = new grpc.Server();
- server.addProtoService(examples.RouteGuide.service, {
+ server.addProtoService(routeguide.RouteGuide.service, {
getFeature: getFeature,
listFeatures: listFeatures,
recordRoute: recordRoute,
diff --git a/src/core/surface/version.c b/src/core/surface/version.c
index d7aaba3868..4b90e06a04 100644
--- a/src/core/surface/version.c
+++ b/src/core/surface/version.c
@@ -37,5 +37,5 @@
#include <grpc/grpc.h>
const char *grpc_version_string(void) {
- return "0.10.1.0";
+ return "0.11.0.0";
}
diff --git a/src/cpp/util/string_ref.cc b/src/cpp/util/string_ref.cc
index 9adc092013..c42033f61f 100644
--- a/src/cpp/util/string_ref.cc
+++ b/src/cpp/util/string_ref.cc
@@ -36,6 +36,7 @@
#include <string.h>
#include <algorithm>
+#include <iostream>
namespace grpc {
diff --git a/src/csharp/build_packages.bat b/src/csharp/build_packages.bat
index 255b7469ab..ea2206e760 100644
--- a/src/csharp/build_packages.bat
+++ b/src/csharp/build_packages.bat
@@ -5,6 +5,9 @@ set VERSION=0.7.0
set CORE_VERSION=0.11.0
set PROTOBUF_VERSION=3.0.0-alpha4
+@rem Packages that depend on prerelease packages (like Google.Protobuf) need to have prerelease suffix as well.
+set VERSION_WITH_BETA=0.7.0-beta
+
@rem Adjust the location of nuget.exe
set NUGET=C:\nuget\nuget.exe
@@ -20,7 +23,7 @@ endlocal
%NUGET% pack ..\..\vsprojects\nuget_package\grpc.native.csharp_ext.nuspec -Version %CORE_VERSION% || goto :error
%NUGET% pack Grpc.Auth\Grpc.Auth.nuspec -Symbols -Version %VERSION% || goto :error
%NUGET% pack Grpc.Core\Grpc.Core.nuspec -Symbols -Version %VERSION% -Properties GrpcNativeCsharpExtVersion=%CORE_VERSION% || goto :error
-%NUGET% pack Grpc.HealthCheck\Grpc.HealthCheck.nuspec -Symbols -Version %VERSION% -Properties ProtobufVersion=%PROTOBUF_VERSION% || goto :error
+%NUGET% pack Grpc.HealthCheck\Grpc.HealthCheck.nuspec -Symbols -Version %VERSION_WITH_BETA% -Properties ProtobufVersion=%PROTOBUF_VERSION% || goto :error
%NUGET% pack Grpc.Tools.nuspec -Version %VERSION% || goto :error
%NUGET% pack Grpc.nuspec -Version %VERSION% || goto :error
diff --git a/src/node/interop/interop_client.js b/src/node/interop/interop_client.js
index 6a8d2633ca..215d42121c 100644
--- a/src/node/interop/interop_client.js
+++ b/src/node/interop/interop_client.js
@@ -44,7 +44,7 @@ var assert = require('assert');
var AUTH_SCOPE = 'https://www.googleapis.com/auth/xapi.zoo';
var AUTH_SCOPE_RESPONSE = 'xapi.zoo';
-var AUTH_USER = ('155450119199-3psnrh1sdr3d8cpj1v46naggf81mhdnk' +
+var AUTH_USER = ('155450119199-vefjjaekcc6cmsd5914v6lqufunmh9ue' +
'@developer.gserviceaccount.com');
var COMPUTE_ENGINE_USER = ('155450119199-r5aaqa2vqoa9g5mv2m6s3m1l293rlmel' +
'@developer.gserviceaccount.com');
@@ -321,7 +321,7 @@ function oauth2Test(expected_user, scope, per_rpc, client, done) {
credential.getAccessToken(function(err, token) {
assert.ifError(err);
var updateMetadata = function(authURI, metadata, callback) {
- metadata.Add('authorization', 'Bearer ' + token);
+ metadata.add('authorization', 'Bearer ' + token);
callback(null, metadata);
};
var makeTestCall = function(error, client_metadata) {
@@ -336,10 +336,10 @@ function oauth2Test(expected_user, scope, per_rpc, client, done) {
}, client_metadata);
};
if (per_rpc) {
- updateMetadata('', {}, makeTestCall);
+ updateMetadata('', new grpc.Metadata(), makeTestCall);
} else {
client.$updateMetadata = updateMetadata;
- makeTestCall(null, {});
+ makeTestCall(null, new grpc.Metadata());
}
});
});
diff --git a/src/node/src/client.js b/src/node/src/client.js
index b427297a8a..7f510231b3 100644
--- a/src/node/src/client.js
+++ b/src/node/src/client.js
@@ -637,7 +637,7 @@ exports.makeClientConstructor = function(methods, serviceName) {
// Remove the optional DNS scheme, trailing port, and trailing backslash
address = address.replace(/^(dns:\/{3})?([^:\/]+)(:\d+)?\/?$/, '$2');
this.$server_address = address;
- this.$auth_uri = 'https://' + this.server_address + '/' + serviceName;
+ this.$auth_uri = 'https://' + this.$server_address + '/' + serviceName;
this.$updateMetadata = updateMetadata;
}
diff --git a/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec
new file mode 100644
index 0000000000..dcb0c4e500
--- /dev/null
+++ b/src/objective-c/examples/RemoteTestClient/RemoteTest.podspec
@@ -0,0 +1,28 @@
+Pod::Spec.new do |s|
+ s.name = "RemoteTest"
+ s.version = "0.0.1"
+ s.license = "New BSD"
+
+ s.ios.deployment_target = "6.0"
+ s.osx.deployment_target = "10.8"
+
+ # Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
+ s.prepare_command = <<-CMD
+ protoc --objc_out=. --objcgrpc_out=. *.proto
+ CMD
+
+ s.subspec "Messages" do |ms|
+ ms.source_files = "*.pbobjc.{h,m}"
+ ms.header_mappings_dir = "."
+ ms.requires_arc = false
+ ms.dependency "Protobuf", "~> 3.0.0-alpha-3"
+ end
+
+ s.subspec "Services" do |ss|
+ ss.source_files = "*.pbrpc.{h,m}"
+ ss.header_mappings_dir = "."
+ ss.requires_arc = true
+ ss.dependency "gRPC", "~> 0.5"
+ ss.dependency "#{s.name}/Messages"
+ end
+end
diff --git a/examples/csharp/Greeter/protos/helloworld.proto b/src/objective-c/examples/RemoteTestClient/empty.proto
index e02ebd94e7..a678048289 100644
--- a/examples/csharp/Greeter/protos/helloworld.proto
+++ b/src/objective-c/examples/RemoteTestClient/empty.proto
@@ -27,26 +27,18 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// TODO(jtattermusch): as of now, C# protobufs don't officially support
-// proto3.
-syntax = "proto2";
+syntax = "proto3";
-option java_package = "io.grpc.examples";
+package grpc.testing;
-package helloworld;
+option objc_class_prefix = "RMT";
-// The greeting service definition.
-service Greeter {
- // Sends a greeting
- rpc SayHello (HelloRequest) returns (HelloReply) {}
-}
-
-// The request message containing the user's name.
-message HelloRequest {
- optional string name = 1;
-}
-
-// The response message containing the greetings
-message HelloReply {
- optional string message = 1;
-}
+// An empty message that you can re-use to avoid defining duplicated empty
+// messages in your project. A typical example is to use it as argument or the
+// return value of a service API. For instance:
+//
+// service Foo {
+// rpc Bar (grpc.testing.Empty) returns (grpc.testing.Empty) { };
+// };
+//
+message Empty {}
diff --git a/src/objective-c/examples/RemoteTestClient/messages.proto b/src/objective-c/examples/RemoteTestClient/messages.proto
new file mode 100644
index 0000000000..85d93c2ff9
--- /dev/null
+++ b/src/objective-c/examples/RemoteTestClient/messages.proto
@@ -0,0 +1,133 @@
+// 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.
+
+// Message definitions to be used by integration test service definitions.
+
+syntax = "proto3";
+
+package grpc.testing;
+
+option objc_class_prefix = "RMT";
+
+// The type of payload that should be returned.
+enum PayloadType {
+ // Compressable text format.
+ COMPRESSABLE = 0;
+
+ // Uncompressable binary format.
+ UNCOMPRESSABLE = 1;
+
+ // Randomly chosen from all other formats defined in this enum.
+ RANDOM = 2;
+}
+
+// A block of data, to simply increase gRPC message size.
+message Payload {
+ // The type of data in body.
+ PayloadType type = 1;
+ // Primary contents of payload.
+ bytes body = 2;
+}
+
+// Unary request.
+message SimpleRequest {
+ // Desired payload type in the response from the server.
+ // If response_type is RANDOM, server randomly chooses one from other formats.
+ PayloadType response_type = 1;
+
+ // Desired payload size in the response from the server.
+ // If response_type is COMPRESSABLE, this denotes the size before compression.
+ int32 response_size = 2;
+
+ // Optional input payload sent along with the request.
+ Payload payload = 3;
+
+ // Whether SimpleResponse should include username.
+ bool fill_username = 4;
+
+ // Whether SimpleResponse should include OAuth scope.
+ bool fill_oauth_scope = 5;
+}
+
+// Unary response, as configured by the request.
+message SimpleResponse {
+ // Payload to increase message size.
+ Payload payload = 1;
+ // The user the request came from, for verifying authentication was
+ // successful when the client expected it.
+ string username = 2;
+ // OAuth scope.
+ string oauth_scope = 3;
+}
+
+// Client-streaming request.
+message StreamingInputCallRequest {
+ // Optional input payload sent along with the request.
+ Payload payload = 1;
+
+ // Not expecting any payload from the response.
+}
+
+// Client-streaming response.
+message StreamingInputCallResponse {
+ // Aggregated size of payloads received from the client.
+ int32 aggregated_payload_size = 1;
+}
+
+// Configuration for a particular response.
+message ResponseParameters {
+ // Desired payload sizes in responses from the server.
+ // If response_type is COMPRESSABLE, this denotes the size before compression.
+ int32 size = 1;
+
+ // Desired interval between consecutive responses in the response stream in
+ // microseconds.
+ int32 interval_us = 2;
+}
+
+// Server-streaming request.
+message StreamingOutputCallRequest {
+ // Desired payload type in the response from the server.
+ // If response_type is RANDOM, the payload from each response in the stream
+ // might be of different types. This is to simulate a mixed type of payload
+ // stream.
+ PayloadType response_type = 1;
+
+ // Configuration for each expected response message.
+ repeated ResponseParameters response_parameters = 2;
+
+ // Optional input payload sent along with the request.
+ Payload payload = 3;
+}
+
+// Server-streaming response, as configured by the request and parameters.
+message StreamingOutputCallResponse {
+ // Payload to increase response size.
+ Payload payload = 1;
+}
diff --git a/src/objective-c/examples/RemoteTestClient/test.proto b/src/objective-c/examples/RemoteTestClient/test.proto
new file mode 100644
index 0000000000..2f5a5489b3
--- /dev/null
+++ b/src/objective-c/examples/RemoteTestClient/test.proto
@@ -0,0 +1,73 @@
+// 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.
+
+// An integration test service that covers all the method signature permutations
+// of unary/streaming requests/responses.
+syntax = "proto3";
+
+import "empty.proto";
+import "messages.proto";
+
+package grpc.testing;
+
+option objc_class_prefix = "RMT";
+
+// A simple service to test the various types of RPCs and experiment with
+// performance with various types of payload.
+service TestService {
+ // One empty request followed by one empty response.
+ rpc EmptyCall(grpc.testing.Empty) returns (grpc.testing.Empty);
+
+ // One request followed by one response.
+ // TODO(Issue 527): Describe required server behavior.
+ rpc UnaryCall(SimpleRequest) returns (SimpleResponse);
+
+ // One request followed by a sequence of responses (streamed download).
+ // The server returns the payload with client desired type and sizes.
+ rpc StreamingOutputCall(StreamingOutputCallRequest)
+ returns (stream StreamingOutputCallResponse);
+
+ // A sequence of requests followed by one response (streamed upload).
+ // The server returns the aggregated size of client payload as the result.
+ rpc StreamingInputCall(stream StreamingInputCallRequest)
+ returns (StreamingInputCallResponse);
+
+ // A sequence of requests with each request served by the server immediately.
+ // As one request could lead to multiple responses, this interface
+ // demonstrates the idea of full duplexing.
+ rpc FullDuplexCall(stream StreamingOutputCallRequest)
+ returns (stream StreamingOutputCallResponse);
+
+ // A sequence of requests followed by a sequence of responses.
+ // The server buffers all the client requests and then serves them in order. A
+ // stream of responses are returned to the client when the server starts with
+ // first request.
+ rpc HalfDuplexCall(stream StreamingOutputCallRequest)
+ returns (stream StreamingOutputCallResponse);
+}
diff --git a/src/objective-c/examples/SwiftSample/AppDelegate.swift b/src/objective-c/examples/SwiftSample/AppDelegate.swift
new file mode 100644
index 0000000000..88027d997b
--- /dev/null
+++ b/src/objective-c/examples/SwiftSample/AppDelegate.swift
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+import UIKit
+
+@UIApplicationMain
+class AppDelegate: UIResponder, UIApplicationDelegate {
+ var window: UIWindow?
+}
diff --git a/src/objective-c/examples/SwiftSample/Base.lproj/Main.storyboard b/src/objective-c/examples/SwiftSample/Base.lproj/Main.storyboard
new file mode 100644
index 0000000000..3a2a49bad8
--- /dev/null
+++ b/src/objective-c/examples/SwiftSample/Base.lproj/Main.storyboard
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
+ <dependencies>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
+ </dependencies>
+ <scenes>
+ <!--View Controller-->
+ <scene sceneID="tne-QT-ifu">
+ <objects>
+ <viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
+ <layoutGuides>
+ <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
+ <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
+ </layoutGuides>
+ <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
+ <rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+ </view>
+ </viewController>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
+ </objects>
+ </scene>
+ </scenes>
+</document>
diff --git a/src/objective-c/examples/SwiftSample/Bridging-Header.h b/src/objective-c/examples/SwiftSample/Bridging-Header.h
new file mode 100644
index 0000000000..33db2dd1cb
--- /dev/null
+++ b/src/objective-c/examples/SwiftSample/Bridging-Header.h
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#ifndef SwiftSample_Bridging_Header_h
+#define SwiftSample_Bridging_Header_h
+
+#import <RxLibrary/GRXWriteable.h>
+#import <RxLibrary/GRXWriter.h>
+#import <RxLibrary/GRXWriter+Immediate.h>
+#import <GRPCClient/GRPCCall.h>
+#import <ProtoRPC/ProtoMethod.h>
+#import <RemoteTest/Test.pbrpc.h>
+
+#endif
diff --git a/src/objective-c/examples/SwiftSample/Images.xcassets/AppIcon.appiconset/Contents.json b/src/objective-c/examples/SwiftSample/Images.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 0000000000..36d2c80d88
--- /dev/null
+++ b/src/objective-c/examples/SwiftSample/Images.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,68 @@
+{
+ "images" : [
+ {
+ "idiom" : "iphone",
+ "size" : "29x29",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "29x29",
+ "scale" : "3x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "40x40",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "40x40",
+ "scale" : "3x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "60x60",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "iphone",
+ "size" : "60x60",
+ "scale" : "3x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "29x29",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "29x29",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "40x40",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "40x40",
+ "scale" : "2x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "76x76",
+ "scale" : "1x"
+ },
+ {
+ "idiom" : "ipad",
+ "size" : "76x76",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+} \ No newline at end of file
diff --git a/src/objective-c/examples/SwiftSample/Info.plist b/src/objective-c/examples/SwiftSample/Info.plist
new file mode 100644
index 0000000000..10f0450b34
--- /dev/null
+++ b/src/objective-c/examples/SwiftSample/Info.plist
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>io.grpc.$(PRODUCT_NAME:rfc1034identifier)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>UILaunchStoryboardName</key>
+ <string>Main</string>
+ <key>UIMainStoryboardFile</key>
+ <string>Main</string>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+ <key>UISupportedInterfaceOrientations~ipad</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
diff --git a/src/objective-c/examples/SwiftSample/Podfile b/src/objective-c/examples/SwiftSample/Podfile
new file mode 100644
index 0000000000..7b5941eef7
--- /dev/null
+++ b/src/objective-c/examples/SwiftSample/Podfile
@@ -0,0 +1,8 @@
+source 'https://github.com/CocoaPods/Specs.git'
+platform :ios, '8.0'
+
+pod 'gRPC', :path => "../../../.."
+pod 'RemoteTest', :path => "../RemoteTestClient"
+
+target 'SwiftSample' do
+end
diff --git a/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj
new file mode 100644
index 0000000000..cfccdd453f
--- /dev/null
+++ b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.pbxproj
@@ -0,0 +1,354 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 253D3A297105CA46DA960A11 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DC58ACA18DCCB1553531B885 /* libPods.a */; };
+ 633BFFC81B950B210007E424 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 633BFFC71B950B210007E424 /* AppDelegate.swift */; };
+ 633BFFCA1B950B210007E424 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 633BFFC91B950B210007E424 /* ViewController.swift */; };
+ 633BFFCD1B950B210007E424 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 633BFFCB1B950B210007E424 /* Main.storyboard */; };
+ 633BFFCF1B950B210007E424 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 633BFFCE1B950B210007E424 /* Images.xcassets */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 12C7B447AA80E624D93B5C54 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
+ 633BFFC21B950B210007E424 /* SwiftSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftSample.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 633BFFC61B950B210007E424 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 633BFFC71B950B210007E424 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
+ 633BFFC91B950B210007E424 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
+ 633BFFCC1B950B210007E424 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
+ 633BFFCE1B950B210007E424 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
+ 6367AD231B951655007FD3A4 /* Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Bridging-Header.h"; sourceTree = "<group>"; };
+ C335CBC4C160E0D9EDEE646B /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
+ DC58ACA18DCCB1553531B885 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 633BFFBF1B950B210007E424 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 253D3A297105CA46DA960A11 /* libPods.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 31F283C976AE97586C17CCD9 /* Pods */ = {
+ isa = PBXGroup;
+ children = (
+ 12C7B447AA80E624D93B5C54 /* Pods.debug.xcconfig */,
+ C335CBC4C160E0D9EDEE646B /* Pods.release.xcconfig */,
+ );
+ name = Pods;
+ sourceTree = "<group>";
+ };
+ 633BFFB91B950B210007E424 = {
+ isa = PBXGroup;
+ children = (
+ 633BFFC41B950B210007E424 /* SwiftSample */,
+ 633BFFC31B950B210007E424 /* Products */,
+ 31F283C976AE97586C17CCD9 /* Pods */,
+ 9D63A7F6423989BA306810CA /* Frameworks */,
+ );
+ sourceTree = "<group>";
+ };
+ 633BFFC31B950B210007E424 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 633BFFC21B950B210007E424 /* SwiftSample.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ 633BFFC41B950B210007E424 /* SwiftSample */ = {
+ isa = PBXGroup;
+ children = (
+ 633BFFC71B950B210007E424 /* AppDelegate.swift */,
+ 633BFFC91B950B210007E424 /* ViewController.swift */,
+ 633BFFCB1B950B210007E424 /* Main.storyboard */,
+ 633BFFCE1B950B210007E424 /* Images.xcassets */,
+ 633BFFC51B950B210007E424 /* Supporting Files */,
+ 6367AD231B951655007FD3A4 /* Bridging-Header.h */,
+ );
+ name = SwiftSample;
+ sourceTree = SOURCE_ROOT;
+ };
+ 633BFFC51B950B210007E424 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ 633BFFC61B950B210007E424 /* Info.plist */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+ 9D63A7F6423989BA306810CA /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ DC58ACA18DCCB1553531B885 /* libPods.a */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 633BFFC11B950B210007E424 /* SwiftSample */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 633BFFE11B950B210007E424 /* Build configuration list for PBXNativeTarget "SwiftSample" */;
+ buildPhases = (
+ 6BEEB33CA2705D7D2F2210E6 /* Check Pods Manifest.lock */,
+ 633BFFBE1B950B210007E424 /* Sources */,
+ 633BFFBF1B950B210007E424 /* Frameworks */,
+ 633BFFC01B950B210007E424 /* Resources */,
+ AC2F6F9AB1C090BB0BEE6E4D /* Copy Pods Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = SwiftSample;
+ productName = SwiftSample;
+ productReference = 633BFFC21B950B210007E424 /* SwiftSample.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 633BFFBA1B950B210007E424 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0640;
+ ORGANIZATIONNAME = gRPC;
+ TargetAttributes = {
+ 633BFFC11B950B210007E424 = {
+ CreatedOnToolsVersion = 6.4;
+ };
+ };
+ };
+ buildConfigurationList = 633BFFBD1B950B210007E424 /* Build configuration list for PBXProject "SwiftSample" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = 633BFFB91B950B210007E424;
+ productRefGroup = 633BFFC31B950B210007E424 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 633BFFC11B950B210007E424 /* SwiftSample */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 633BFFC01B950B210007E424 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 633BFFCD1B950B210007E424 /* Main.storyboard in Resources */,
+ 633BFFCF1B950B210007E424 /* Images.xcassets in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ 6BEEB33CA2705D7D2F2210E6 /* Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "Check Pods Manifest.lock";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
+ showEnvVarsInLog = 0;
+ };
+ AC2F6F9AB1C090BB0BEE6E4D /* Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "Copy Pods Resources";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 633BFFBE1B950B210007E424 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 633BFFCA1B950B210007E424 /* ViewController.swift in Sources */,
+ 633BFFC81B950B210007E424 /* AppDelegate.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ 633BFFCB1B950B210007E424 /* Main.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 633BFFCC1B950B210007E424 /* Base */,
+ );
+ name = Main.storyboard;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 633BFFDF1B950B210007E424 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.4;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 633BFFE01B950B210007E424 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.4;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 633BFFE21B950B210007E424 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 12C7B447AA80E624D93B5C54 /* Pods.debug.xcconfig */;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ INFOPLIST_FILE = Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_OBJC_BRIDGING_HEADER = "Bridging-Header.h";
+ USER_HEADER_SEARCH_PATHS = "Pods/**";
+ };
+ name = Debug;
+ };
+ 633BFFE31B950B210007E424 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = C335CBC4C160E0D9EDEE646B /* Pods.release.xcconfig */;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ INFOPLIST_FILE = Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SWIFT_OBJC_BRIDGING_HEADER = "Bridging-Header.h";
+ USER_HEADER_SEARCH_PATHS = "Pods/**";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 633BFFBD1B950B210007E424 /* Build configuration list for PBXProject "SwiftSample" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 633BFFDF1B950B210007E424 /* Debug */,
+ 633BFFE01B950B210007E424 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 633BFFE11B950B210007E424 /* Build configuration list for PBXNativeTarget "SwiftSample" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 633BFFE21B950B210007E424 /* Debug */,
+ 633BFFE31B950B210007E424 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 633BFFBA1B950B210007E424 /* Project object */;
+}
diff --git a/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000000..3b0f1c15b2
--- /dev/null
+++ b/src/objective-c/examples/SwiftSample/SwiftSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:SwiftSample.xcodeproj">
+ </FileRef>
+</Workspace>
diff --git a/src/objective-c/examples/SwiftSample/ViewController.swift b/src/objective-c/examples/SwiftSample/ViewController.swift
new file mode 100644
index 0000000000..e4e7aeae49
--- /dev/null
+++ b/src/objective-c/examples/SwiftSample/ViewController.swift
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+import UIKit
+
+class ViewController: UIViewController {
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+
+ let RemoteHost = "grpc-test.sandbox.google.com"
+
+ let request = RMTSimpleRequest()
+ request.responseSize = 10
+ request.fillUsername = true
+ request.fillOauthScope = true
+
+ // Example gRPC call using a generated proto client library:
+
+ let service = RMTTestService(host: RemoteHost)
+ service.unaryCallWithRequest(request) { (response: RMTSimpleResponse?, error: NSError?) in
+ if let response = response {
+ NSLog("Finished successfully with response:\n\(response)")
+ } else {
+ NSLog("Finished with error: \(error!)")
+ }
+ }
+
+ // Same example call using the generic gRPC client library:
+
+ let method = ProtoMethod(package: "grpc.testing", service: "TestService", method: "UnaryCall")
+
+ let requestsWriter = GRXWriter(value: request.data())
+
+ let call = GRPCCall(host: RemoteHost, path: method.HTTPPath, requestsWriter: requestsWriter)
+
+ let responsesWriteable = GRXWriteable { (value: AnyObject?, error: NSError?) in
+ if let value = value as? NSData {
+ NSLog("Received response:\n\(RMTSimpleResponse(data: value, error: nil))")
+ } else {
+ NSLog("Finished with error: \(error!)")
+ }
+ }
+
+ call.startWithWriteable(responsesWriteable)
+ }
+}
diff --git a/src/php/composer.json b/src/php/composer.json
index 2d0fe0c87a..1d41f847ac 100644
--- a/src/php/composer.json
+++ b/src/php/composer.json
@@ -1,7 +1,7 @@
{
"name": "grpc/grpc",
"description": "gRPC library for PHP",
- "version": "0.5.1",
+ "version": "0.6.0",
"homepage": "http://grpc.io",
"license": "BSD-3-Clause",
"repositories": [
diff --git a/src/php/ext/grpc/README.md b/src/php/ext/grpc/README.md
index 88d2c481ec..6e1cb2002f 100644
--- a/src/php/ext/grpc/README.md
+++ b/src/php/ext/grpc/README.md
@@ -4,7 +4,7 @@ gRPC PHP Extension
# Requirements
* PHP 5.5+
- * [gRPC core library](https://github.com/grpc/grpc) 0.10.0
+ * [gRPC core library](https://github.com/grpc/grpc) 0.11.0
# Installation
@@ -22,26 +22,21 @@ Clone the gRPC source code repository
$ git clone https://github.com/grpc/grpc.git
```
-Build and install the Protocol Buffers compiler (protoc)
+Build and install the gRPC C core libraries
-```
-$ # from grpc
-$ git checkout --track origin/release-0_9
+```sh
+$ cd grpc
+$ git checkout --track origin/release-0_11
$ git pull --recurse-submodules && git submodule update --init --recursive
-$ cd third_party/protobuf
-$ ./autogen.sh
-$ ./configure
$ make
-$ make check
$ sudo make install
```
-Build and install the gRPC C core library
+Note: you may encounter a warning about the Protobuf compiler `protoc` 3.0.0+ not being installed. The following might help, and will be useful later on when we need to compile the `protoc-gen-php` tool.
```sh
-$ # from grpc
-$ make
-$ sudo make install
+$ cd grpc/third_party/protobuf
+$ sudo make install # 'make' should have been run by core grpc
```
## Install the gRPC PHP extension
@@ -55,7 +50,7 @@ $ sudo pecl install grpc
Note: before a stable release, you may need to do
```sh
-$ sudo pecl install grpc-0.5.1
+$ sudo pecl install grpc-beta
```
OR
diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c
index 252623d0c3..3b99de7538 100644
--- a/src/php/ext/grpc/call.c
+++ b/src/php/ext/grpc/call.c
@@ -265,6 +265,9 @@ PHP_METHOD(Call, startBatch) {
HashTable *array_hash;
HashPosition array_pointer;
HashTable *status_hash;
+ HashTable *message_hash;
+ zval **message_value;
+ zval **message_flags;
char *key;
uint key_len;
ulong index;
@@ -319,13 +322,33 @@ PHP_METHOD(Call, startBatch) {
metadata.metadata;
break;
case GRPC_OP_SEND_MESSAGE:
- if (Z_TYPE_PP(value) != IS_STRING) {
+ if (Z_TYPE_PP(value) != IS_ARRAY) {
+ zend_throw_exception(spl_ce_InvalidArgumentException,
+ "Expected an array for send message",
+ 1 TSRMLS_CC);
+ goto cleanup;
+ }
+ message_hash = Z_ARRVAL_PP(value);
+ if (zend_hash_find(message_hash, "flags", sizeof("flags"),
+ (void **)&message_flags) == SUCCESS) {
+ if (Z_TYPE_PP(message_flags) != IS_LONG) {
+ zend_throw_exception(spl_ce_InvalidArgumentException,
+ "Expected an int for message flags",
+ 1 TSRMLS_CC);
+ }
+ ops[op_num].flags = Z_LVAL_PP(message_flags) & GRPC_WRITE_USED_MASK;
+ }
+ if (zend_hash_find(message_hash, "message", sizeof("message"),
+ (void **)&message_value) != SUCCESS ||
+ Z_TYPE_PP(message_value) != IS_STRING) {
zend_throw_exception(spl_ce_InvalidArgumentException,
"Expected a string for send message",
1 TSRMLS_CC);
+ goto cleanup;
}
ops[op_num].data.send_message =
- string_to_byte_buffer(Z_STRVAL_PP(value), Z_STRLEN_PP(value));
+ string_to_byte_buffer(Z_STRVAL_PP(message_value),
+ Z_STRLEN_PP(message_value));
break;
case GRPC_OP_SEND_CLOSE_FROM_CLIENT:
break;
diff --git a/src/php/ext/grpc/package.xml b/src/php/ext/grpc/package.xml
index bc2a05923b..381ae23b45 100644
--- a/src/php/ext/grpc/package.xml
+++ b/src/php/ext/grpc/package.xml
@@ -10,43 +10,48 @@
<email>grpc-packages@google.com</email>
<active>yes</active>
</lead>
- <date>2015-07-09</date>
- <time>21:47:27</time>
+ <date>2015-09-01</date>
+ <time>13:37:33</time>
<version>
- <release>0.5.1</release>
- <api>0.5.1</api>
+ <release>0.6.0</release>
+ <api>0.6.0</api>
</version>
<stability>
- <release>alpha</release>
- <api>alpha</api>
+ <release>beta</release>
+ <api>beta</api>
</stability>
<license>BSD</license>
<notes>
-Update to wrap gRPC C Core version 0.10.0
+ - support per message compression disable
+ - expose per-call host override option
+ - expose connectivity API
+ - expose channel target and call peer
+ - add user-agent
+ - update to wrap gRPC C core library beta version 0.11.0
</notes>
<contents>
<dir baseinstalldir="/" name="/">
<file baseinstalldir="/" md5sum="6f19828fb869b7b8a590cbb76b4f996d" name="byte_buffer.c" role="src" />
<file baseinstalldir="/" md5sum="c8de0f819499c48adfc8d7f472c0196b" name="byte_buffer.h" role="src" />
- <file baseinstalldir="/" md5sum="cb45b62f767ae7b4377761df696649fc" name="call.c" role="src" />
+ <file baseinstalldir="/" md5sum="d64c9005993de02abac55664b0b9e0b2" name="call.c" role="src" />
<file baseinstalldir="/" md5sum="26acbf04c30162c2d2aca4688bb2aec8" name="call.h" role="src" />
- <file baseinstalldir="/" md5sum="50837fbdb2892795f1871b22e5979762" name="channel.c" role="src" />
- <file baseinstalldir="/" md5sum="f1b66029daeced20b47cf00cc6523fc8" name="channel.h" role="src" />
- <file baseinstalldir="/" md5sum="81a1193e93d8b6602add8ac360de565b" name="completion_queue.c" role="src" />
+ <file baseinstalldir="/" md5sum="15e56239b32c803f073e8a2b9f96e8c3" name="channel.c" role="src" />
+ <file baseinstalldir="/" md5sum="ed4b00c0cf3702b115d0cfa87450dc09" name="channel.h" role="src" />
+ <file baseinstalldir="/" md5sum="55ab7a42f9dd9bfc7e28a61cfc5fca63" name="completion_queue.c" role="src" />
<file baseinstalldir="/" md5sum="f10b5bb232d74a6878e829e2e76cdaa2" name="completion_queue.h" role="src" />
<file baseinstalldir="/" md5sum="a22f8eac0164761058cc4d9eb2ceb069" name="config.m4" role="src" />
- <file baseinstalldir="/" md5sum="8c3f1e11dac623001378bfd53b554f08" name="credentials.c" role="src" />
+ <file baseinstalldir="/" md5sum="588752c908f7bc1663f7b8fc922ae661" name="credentials.c" role="src" />
<file baseinstalldir="/" md5sum="6988d6e97c19c8f8e3eb92371cf8246b" name="credentials.h" role="src" />
<file baseinstalldir="/" md5sum="38a1bc979d810c36ebc2a52d4b7b5319" name="CREDITS" role="doc" />
<file baseinstalldir="/" md5sum="3f35b472bbdef5a788cd90617d7d0847" name="LICENSE" role="doc" />
- <file baseinstalldir="/" md5sum="6aaa7a290122d230f2d8c4e4e05da4a9" name="php_grpc.c" role="src" />
+ <file baseinstalldir="/" md5sum="6a550516a1423def0786851c76f87c85" name="php_grpc.c" role="src" />
<file baseinstalldir="/" md5sum="673b07859d9f69232f8a754c56780686" name="php_grpc.h" role="src" />
<file baseinstalldir="/" md5sum="c1d0b42fd77b7d6740bf7744bee90af5" name="README.md" role="doc" />
- <file baseinstalldir="/" md5sum="30997dd423403e1f8ad09dcee598e5c4" name="server.c" role="src" />
+ <file baseinstalldir="/" md5sum="3e4e960454ebb2fc7b78a840493f5315" name="server.c" role="src" />
<file baseinstalldir="/" md5sum="4b730f06d14cbbb0642bdbd194749595" name="server.h" role="src" />
- <file baseinstalldir="/" md5sum="f6930beafb6c0e061899262f2f077e98" name="server_credentials.c" role="src" />
+ <file baseinstalldir="/" md5sum="34ea881f1fe960d190d0713422cf8916" name="server_credentials.c" role="src" />
<file baseinstalldir="/" md5sum="9c4b4cc06356a8a39a16a085a9b85996" name="server_credentials.h" role="src" />
- <file baseinstalldir="/" md5sum="c89c623cd17177ebde18313fc5c17122" name="timeval.c" role="src" />
+ <file baseinstalldir="/" md5sum="7646ec78cb133f66ba59e03c6f451e39" name="timeval.c" role="src" />
<file baseinstalldir="/" md5sum="496e27a100b4d93ca3fb35c924c5e163" name="timeval.h" role="src" />
</dir>
</contents>
@@ -93,5 +98,25 @@ First alpha release
Update to wrap gRPC C Core version 0.10.0
</notes>
</release>
+ <release>
+ <version>
+ <release>0.6.0</release>
+ <api>0.6.0</api>
+ </version>
+ <stability>
+ <release>beta</release>
+ <api>beta</api>
+ </stability>
+ <date>2015-09-01</date>
+ <license>BSD</license>
+ <notes>
+ - support per message compression disable
+ - expose per-call host override option
+ - expose connectivity API
+ - expose channel target and call peer
+ - add user-agent
+ - update to wrap gRPC C core library beta version 0.11.0
+ </notes>
+ </release>
</changelog>
</package>
diff --git a/src/php/lib/Grpc/AbstractCall.php b/src/php/lib/Grpc/AbstractCall.php
index 35057224f8..a3c7a9e017 100644
--- a/src/php/lib/Grpc/AbstractCall.php
+++ b/src/php/lib/Grpc/AbstractCall.php
@@ -92,4 +92,4 @@ abstract class AbstractCall {
}
return call_user_func($this->deserialize, $value);
}
-} \ No newline at end of file
+}
diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php
index 2e980c5eed..381b114399 100755
--- a/src/php/lib/Grpc/BaseStub.php
+++ b/src/php/lib/Grpc/BaseStub.php
@@ -168,7 +168,8 @@ class BaseStub {
public function _simpleRequest($method,
$argument,
callable $deserialize,
- $metadata = array()) {
+ $metadata = array(),
+ $options = array()) {
list($actual_metadata, $timeout) = $this->_extract_timeout_from_metadata($metadata);
$call = new UnaryCall($this->channel, $method, $deserialize, $timeout);
$jwt_aud_uri = $this->_get_jwt_aud_uri($method);
@@ -177,7 +178,7 @@ class BaseStub {
$actual_metadata,
$jwt_aud_uri);
}
- $call->start($argument, $actual_metadata);
+ $call->start($argument, $actual_metadata, $options);
return $call;
}
@@ -193,7 +194,6 @@ class BaseStub {
* @return ClientStreamingSurfaceActiveCall The active call object
*/
public function _clientStreamRequest($method,
- $arguments,
callable $deserialize,
$metadata = array()) {
list($actual_metadata, $timeout) = $this->_extract_timeout_from_metadata($metadata);
@@ -204,7 +204,7 @@ class BaseStub {
$actual_metadata,
$jwt_aud_uri);
}
- $call->start($arguments, $actual_metadata);
+ $call->start($actual_metadata);
return $call;
}
@@ -221,7 +221,8 @@ class BaseStub {
public function _serverStreamRequest($method,
$argument,
callable $deserialize,
- $metadata = array()) {
+ $metadata = array(),
+ $options = array()) {
list($actual_metadata, $timeout) = $this->_extract_timeout_from_metadata($metadata);
$call = new ServerStreamingCall($this->channel, $method, $deserialize, $timeout);
$jwt_aud_uri = $this->_get_jwt_aud_uri($method);
@@ -230,7 +231,7 @@ class BaseStub {
$actual_metadata,
$jwt_aud_uri);
}
- $call->start($argument, $actual_metadata);
+ $call->start($argument, $actual_metadata, $options);
return $call;
}
diff --git a/src/php/lib/Grpc/BidiStreamingCall.php b/src/php/lib/Grpc/BidiStreamingCall.php
index 76c642bef4..c432fd52d8 100644
--- a/src/php/lib/Grpc/BidiStreamingCall.php
+++ b/src/php/lib/Grpc/BidiStreamingCall.php
@@ -42,7 +42,7 @@ class BidiStreamingCall extends AbstractCall {
* Start the call
* @param array $metadata Metadata to send with the call, if applicable
*/
- public function start($metadata) {
+ public function start($metadata = array()) {
$this->call->startBatch([OP_SEND_INITIAL_METADATA => $metadata]);
}
@@ -66,9 +66,15 @@ class BidiStreamingCall extends AbstractCall {
* Write a single message to the server. This cannot be called after
* writesDone is called.
* @param ByteBuffer $data The data to write
+ * @param array $options an array of options, possible keys:
+ * 'flags' => a number
*/
- public function write($data) {
- $this->call->startBatch([OP_SEND_MESSAGE => $data->serialize()]);
+ public function write($data, $options = array()) {
+ $message_array = ['message' => $data->serialize()];
+ if (isset($options['flags'])) {
+ $message_array['flags'] = $options['flags'];
+ }
+ $this->call->startBatch([OP_SEND_MESSAGE => $message_array]);
}
/**
@@ -86,7 +92,7 @@ class BidiStreamingCall extends AbstractCall {
public function getStatus() {
$status_event = $this->call->startBatch([
OP_RECV_STATUS_ON_CLIENT => true
- ]);
+ ]);
return $status_event->status;
}
} \ No newline at end of file
diff --git a/src/php/lib/Grpc/ClientStreamingCall.php b/src/php/lib/Grpc/ClientStreamingCall.php
index 61439d3f47..b96c17e751 100644
--- a/src/php/lib/Grpc/ClientStreamingCall.php
+++ b/src/php/lib/Grpc/ClientStreamingCall.php
@@ -40,15 +40,25 @@ namespace Grpc;
class ClientStreamingCall extends AbstractCall {
/**
* Start the call.
- * @param Traversable $arg_iter The iterator of arguments to send
* @param array $metadata Metadata to send with the call, if applicable
*/
- public function start($arg_iter, $metadata = array()) {
- $event = $this->call->startBatch([OP_SEND_INITIAL_METADATA => $metadata]);
- foreach($arg_iter as $arg) {
- $this->call->startBatch([OP_SEND_MESSAGE => $arg->serialize()]);
+ public function start($metadata = array()) {
+ $this->call->startBatch([OP_SEND_INITIAL_METADATA => $metadata]);
+ }
+
+ /**
+ * Write a single message to the server. This cannot be called after
+ * wait is called.
+ * @param ByteBuffer $data The data to write
+ * @param array $options an array of options, possible keys:
+ * 'flags' => a number
+ */
+ public function write($data, $options = array()) {
+ $message_array = ['message' => $data->serialize()];
+ if (isset($options['flags'])) {
+ $message_array['flags'] = $options['flags'];
}
- $this->call->startBatch([OP_SEND_CLOSE_FROM_CLIENT => true]);
+ $this->call->startBatch([OP_SEND_MESSAGE => $message_array]);
}
/**
@@ -57,6 +67,7 @@ class ClientStreamingCall extends AbstractCall {
*/
public function wait() {
$event = $this->call->startBatch([
+ OP_SEND_CLOSE_FROM_CLIENT => true,
OP_RECV_INITIAL_METADATA => true,
OP_RECV_MESSAGE => true,
OP_RECV_STATUS_ON_CLIENT => true]);
diff --git a/src/php/lib/Grpc/ServerStreamingCall.php b/src/php/lib/Grpc/ServerStreamingCall.php
index 631c863345..a93c1a5d5e 100644
--- a/src/php/lib/Grpc/ServerStreamingCall.php
+++ b/src/php/lib/Grpc/ServerStreamingCall.php
@@ -40,14 +40,20 @@ namespace Grpc;
class ServerStreamingCall extends AbstractCall {
/**
* Start the call
- * @param $arg The argument to send
+ * @param $data The data to send
* @param array $metadata Metadata to send with the call, if applicable
+ * @param array $options an array of options, possible keys:
+ * 'flags' => a number
*/
- public function start($arg, $metadata = array()) {
+ public function start($data, $metadata = array(), $options = array()) {
+ $message_array = ['message' => $data->serialize()];
+ if (isset($options['flags'])) {
+ $message_array['flags'] = $options['flags'];
+ }
$event = $this->call->startBatch([
OP_SEND_INITIAL_METADATA => $metadata,
OP_RECV_INITIAL_METADATA => true,
- OP_SEND_MESSAGE => $arg->serialize(),
+ OP_SEND_MESSAGE => $message_array,
OP_SEND_CLOSE_FROM_CLIENT => true]);
$this->metadata = $event->metadata;
}
@@ -71,7 +77,7 @@ class ServerStreamingCall extends AbstractCall {
public function getStatus() {
$status_event = $this->call->startBatch([
OP_RECV_STATUS_ON_CLIENT => true
- ]);
+ ]);
return $status_event->status;
}
-} \ No newline at end of file
+}
diff --git a/src/php/lib/Grpc/UnaryCall.php b/src/php/lib/Grpc/UnaryCall.php
index 97a10a40f4..38af6b1d74 100644
--- a/src/php/lib/Grpc/UnaryCall.php
+++ b/src/php/lib/Grpc/UnaryCall.php
@@ -40,14 +40,20 @@ namespace Grpc;
class UnaryCall extends AbstractCall {
/**
* Start the call
- * @param $arg The argument to send
+ * @param $data The data to send
* @param array $metadata Metadata to send with the call, if applicable
+ * @param array $options an array of options, possible keys:
+ * 'flags' => a number
*/
- public function start($arg, $metadata = array()) {
+ public function start($data, $metadata = array(), $options = array()) {
+ $message_array = ['message' => $data->serialize()];
+ if (isset($options['flags'])) {
+ $message_array['flags'] = $options['flags'];
+ }
$event = $this->call->startBatch([
OP_SEND_INITIAL_METADATA => $metadata,
OP_RECV_INITIAL_METADATA => true,
- OP_SEND_MESSAGE => $arg->serialize(),
+ OP_SEND_MESSAGE => $message_array,
OP_SEND_CLOSE_FROM_CLIENT => true]);
$this->metadata = $event->metadata;
}
@@ -62,4 +68,4 @@ class UnaryCall extends AbstractCall {
OP_RECV_STATUS_ON_CLIENT => true]);
return array($this->deserializeResponse($event->message), $event->status);
}
-} \ No newline at end of file
+}
diff --git a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php
index a368dd4ee0..9cee188666 100644
--- a/src/php/tests/generated_code/AbstractGeneratedCodeTest.php
+++ b/src/php/tests/generated_code/AbstractGeneratedCodeTest.php
@@ -51,6 +51,18 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase {
$this->assertTrue(is_string(self::$client->getTarget()));
}
+ public function testWriteFlags() {
+ $div_arg = new math\DivArgs();
+ $div_arg->setDividend(7);
+ $div_arg->setDivisor(4);
+ $call = self::$client->Div($div_arg, array(), array('flags' => Grpc\WRITE_NO_COMPRESS));
+ $this->assertTrue(is_string($call->getPeer()));
+ list($response, $status) = $call->wait();
+ $this->assertSame(1, $response->getQuotient());
+ $this->assertSame(3, $response->getRemainder());
+ $this->assertSame(\Grpc\STATUS_OK, $status->code);
+ }
+
public function testSimpleRequest() {
$div_arg = new math\DivArgs();
$div_arg->setDividend(7);
@@ -79,15 +91,13 @@ abstract class AbstractGeneratedCodeTest extends PHPUnit_Framework_TestCase {
}
public function testClientStreaming() {
- $num_iter = function() {
- for ($i = 0; $i < 7; $i++) {
- $num = new math\Num();
- $num->setNum($i);
- yield $num;
- }
- };
- $call = self::$client->Sum($num_iter());
+ $call = self::$client->Sum();
$this->assertTrue(is_string($call->getPeer()));
+ for ($i = 0; $i < 7; $i++) {
+ $num = new math\Num();
+ $num->setNum($i);
+ $call->write($num);
+ }
list($response, $status) = $call->wait();
$this->assertSame(21, $response->getNum());
$this->assertSame(\Grpc\STATUS_OK, $status->code);
diff --git a/src/php/tests/interop/interop_client.php b/src/php/tests/interop/interop_client.php
index bd15ee4303..d55d5629b7 100755
--- a/src/php/tests/interop/interop_client.php
+++ b/src/php/tests/interop/interop_client.php
@@ -173,7 +173,11 @@ function clientStreaming($stub) {
return $request;
}, $request_lengths);
- list($result, $status) = $stub->StreamingInputCall($requests)->wait();
+ $call = $stub->StreamingInputCall();
+ foreach ($requests as $request) {
+ $call->write($request);
+ }
+ list($result, $status) = $call->wait();
hardAssert($status->code === Grpc\STATUS_OK, 'Call did not complete successfully');
hardAssert($result->getAggregatedPayloadSize() === 74922,
'aggregated_payload_size was incorrect');
@@ -247,6 +251,19 @@ function pingPong($stub) {
}
/**
+ * Run the cancel_after_begin test.
+ * Passes when run against the Node server as of 2015-08-28
+ * @param $stub Stub object that has service methods.
+ */
+function cancelAfterBegin($stub) {
+ $call = $stub->StreamingInputCall();
+ $call->cancel();
+ list($result, $status) = $call->wait();
+ hardAssert($status->code === Grpc\STATUS_CANCELLED,
+ 'Call status was not CANCELLED');
+}
+
+/**
* Run the cancel_after_first_response test.
* Passes when run against the Node server as of 2015-04-30
* @param $stub Stub object that has service methods.
@@ -353,6 +370,9 @@ switch ($args['test_case']) {
case 'ping_pong':
pingPong($stub);
break;
+ case 'cancel_after_begin':
+ cancelAfterBegin($stub);
+ break;
case 'cancel_after_first_response':
cancelAfterFirstResponse($stub);
break;
@@ -368,11 +388,7 @@ switch ($args['test_case']) {
case 'jwt_token_creds':
jwtTokenCreds($stub, $args);
break;
- case 'cancel_after_begin':
- // Currently unimplementable with the current API design
- // Specifically, in the ClientStreamingCall->start() method, the
- // messages are sent immediately after metadata is sent. There is
- // currently no way to cancel before messages are sent.
default:
+ echo "Unsupported test case $args[test_case]\n";
exit(1);
}
diff --git a/src/php/tests/unit_tests/EndToEndTest.php b/src/php/tests/unit_tests/EndToEndTest.php
index 4c0cf91d51..bd464f939f 100755
--- a/src/php/tests/unit_tests/EndToEndTest.php
+++ b/src/php/tests/unit_tests/EndToEndTest.php
@@ -91,6 +91,51 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
unset($server_call);
}
+ public function testMessageWriteFlags() {
+ $deadline = Grpc\Timeval::infFuture();
+ $req_text = 'message_write_flags_test';
+ $status_text = 'xyz';
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline);
+
+ $event = $call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_MESSAGE => ['message' => $req_text,
+ 'flags' => Grpc\WRITE_NO_COMPRESS],
+ Grpc\OP_SEND_CLOSE_FROM_CLIENT => true
+ ]);
+
+ $this->assertTrue($event->send_metadata);
+ $this->assertTrue($event->send_close);
+
+ $event = $this->server->requestCall();
+ $this->assertSame('dummy_method', $event->method);
+ $server_call = $event->call;
+
+ $event = $server_call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_STATUS_FROM_SERVER => [
+ 'metadata' => [],
+ 'code' => Grpc\STATUS_OK,
+ 'details' => $status_text
+ ],
+ ]);
+
+ $event = $call->startBatch([
+ Grpc\OP_RECV_INITIAL_METADATA => true,
+ Grpc\OP_RECV_STATUS_ON_CLIENT => true
+ ]);
+
+ $status = $event->status;
+ $this->assertSame([], $status->metadata);
+ $this->assertSame(Grpc\STATUS_OK, $status->code);
+ $this->assertSame($status_text, $status->details);
+
+ unset($call);
+ unset($server_call);
+ }
+
public function testClientServerFullRequestResponse() {
$deadline = Grpc\Timeval::infFuture();
$req_text = 'client_server_full_request_response';
@@ -104,7 +149,7 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
$event = $call->startBatch([
Grpc\OP_SEND_INITIAL_METADATA => [],
Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
- Grpc\OP_SEND_MESSAGE => $req_text
+ Grpc\OP_SEND_MESSAGE => ['message' => $req_text],
]);
$this->assertTrue($event->send_metadata);
@@ -117,7 +162,7 @@ class EndToEndTest extends PHPUnit_Framework_TestCase{
$event = $server_call->startBatch([
Grpc\OP_SEND_INITIAL_METADATA => [],
- Grpc\OP_SEND_MESSAGE => $reply_text,
+ Grpc\OP_SEND_MESSAGE => ['message' => $reply_text],
Grpc\OP_SEND_STATUS_FROM_SERVER => [
'metadata' => [],
'code' => Grpc\STATUS_OK,
diff --git a/src/php/tests/unit_tests/SecureEndToEndTest.php b/src/php/tests/unit_tests/SecureEndToEndTest.php
index 60341b983d..d7fca14a0d 100755
--- a/src/php/tests/unit_tests/SecureEndToEndTest.php
+++ b/src/php/tests/unit_tests/SecureEndToEndTest.php
@@ -107,6 +107,53 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{
unset($server_call);
}
+ public function testMessageWriteFlags() {
+ $deadline = Grpc\Timeval::infFuture();
+ $req_text = 'message_write_flags_test';
+ $status_text = 'xyz';
+ $call = new Grpc\Call($this->channel,
+ 'dummy_method',
+ $deadline,
+ $this->host_override);
+
+ $event = $call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_MESSAGE => ['message' => $req_text,
+ 'flags' => Grpc\WRITE_NO_COMPRESS],
+ Grpc\OP_SEND_CLOSE_FROM_CLIENT => true
+ ]);
+
+ $this->assertTrue($event->send_metadata);
+ $this->assertTrue($event->send_close);
+
+ $event = $this->server->requestCall();
+ $this->assertSame('dummy_method', $event->method);
+ $server_call = $event->call;
+
+ $event = $server_call->startBatch([
+ Grpc\OP_SEND_INITIAL_METADATA => [],
+ Grpc\OP_SEND_STATUS_FROM_SERVER => [
+ 'metadata' => [],
+ 'code' => Grpc\STATUS_OK,
+ 'details' => $status_text
+ ],
+ ]);
+
+ $event = $call->startBatch([
+ Grpc\OP_RECV_INITIAL_METADATA => true,
+ Grpc\OP_RECV_STATUS_ON_CLIENT => true
+ ]);
+
+ $this->assertSame([], $event->metadata);
+ $status = $event->status;
+ $this->assertSame([], $status->metadata);
+ $this->assertSame(Grpc\STATUS_OK, $status->code);
+ $this->assertSame($status_text, $status->details);
+
+ unset($call);
+ unset($server_call);
+ }
+
public function testClientServerFullRequestResponse() {
$deadline = Grpc\Timeval::infFuture();
$req_text = 'client_server_full_request_response';
@@ -121,7 +168,7 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{
$event = $call->startBatch([
Grpc\OP_SEND_INITIAL_METADATA => [],
Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
- Grpc\OP_SEND_MESSAGE => $req_text
+ Grpc\OP_SEND_MESSAGE => ['message' => $req_text]
]);
$this->assertTrue($event->send_metadata);
@@ -134,7 +181,7 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase{
$event = $server_call->startBatch([
Grpc\OP_SEND_INITIAL_METADATA => [],
- Grpc\OP_SEND_MESSAGE => $reply_text,
+ Grpc\OP_SEND_MESSAGE => ['message' => $reply_text],
Grpc\OP_SEND_STATUS_FROM_SERVER => [
'metadata' => [],
'code' => Grpc\STATUS_OK,
diff --git a/src/python/README.md b/src/python/README.md
index a21deb33ef..67d1a173a2 100644
--- a/src/python/README.md
+++ b/src/python/README.md
@@ -4,7 +4,7 @@ The Python facility of gRPC.
Status
-------
-Alpha : Ready for early adopters
+Beta : Core behavior well-used and proven; bugs lurk off the beaten path.
PREREQUISITES
-------------
diff --git a/src/python/grpcio/grpc/_adapter/_c/types.h b/src/python/grpcio/grpc/_adapter/_c/types.h
index ec0687a9fd..31fd470d36 100644
--- a/src/python/grpcio/grpc/_adapter/_c/types.h
+++ b/src/python/grpcio/grpc/_adapter/_c/types.h
@@ -112,6 +112,8 @@ void pygrpc_Call_dealloc(Call *self);
PyObject *pygrpc_Call_start_batch(Call *self, PyObject *args, PyObject *kwargs);
PyObject *pygrpc_Call_cancel(Call *self, PyObject *args, PyObject *kwargs);
PyObject *pygrpc_Call_peer(Call *self);
+PyObject *pygrpc_Call_set_credentials(Call *self, PyObject *args,
+ PyObject *kwargs);
extern PyTypeObject pygrpc_Call_type;
diff --git a/src/python/grpcio/grpc/_adapter/_c/types/call.c b/src/python/grpcio/grpc/_adapter/_c/types/call.c
index 42a50151f6..5604aba39d 100644
--- a/src/python/grpcio/grpc/_adapter/_c/types/call.c
+++ b/src/python/grpcio/grpc/_adapter/_c/types/call.c
@@ -43,6 +43,8 @@ PyMethodDef pygrpc_Call_methods[] = {
{"start_batch", (PyCFunction)pygrpc_Call_start_batch, METH_KEYWORDS, ""},
{"cancel", (PyCFunction)pygrpc_Call_cancel, METH_KEYWORDS, ""},
{"peer", (PyCFunction)pygrpc_Call_peer, METH_NOARGS, ""},
+ {"set_credentials", (PyCFunction)pygrpc_Call_set_credentials, METH_KEYWORDS,
+ ""},
{NULL}
};
const char pygrpc_Call_doc[] = "See grpc._adapter._types.Call.";
@@ -169,3 +171,16 @@ PyObject *pygrpc_Call_peer(Call *self) {
gpr_free(peer);
return py_peer;
}
+PyObject *pygrpc_Call_set_credentials(Call *self, PyObject *args,
+ PyObject *kwargs) {
+ ClientCredentials *creds;
+ grpc_call_error errcode;
+ static char *keywords[] = {"creds", NULL};
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kwargs, "O!:set_credentials", keywords,
+ &pygrpc_ClientCredentials_type, &creds)) {
+ return NULL;
+ }
+ errcode = grpc_call_set_credentials(self->c_call, creds->c_creds);
+ return PyInt_FromLong(errcode);
+}
diff --git a/src/python/grpcio/grpc/_adapter/_intermediary_low.py b/src/python/grpcio/grpc/_adapter/_intermediary_low.py
index 06358e72bc..735ad205a4 100644
--- a/src/python/grpcio/grpc/_adapter/_intermediary_low.py
+++ b/src/python/grpcio/grpc/_adapter/_intermediary_low.py
@@ -163,6 +163,9 @@ class Call(object):
def cancel(self):
return self._internal.cancel()
+ def set_credentials(self, creds):
+ return self._internal.set_credentials(creds)
+
class Channel(object):
"""Adapter from old _low.Channel interface to new _low.Channel."""
diff --git a/src/python/grpcio/grpc/_adapter/_low.py b/src/python/grpcio/grpc/_adapter/_low.py
index 3859ebb0e2..70ceb2a911 100644
--- a/src/python/grpcio/grpc/_adapter/_low.py
+++ b/src/python/grpcio/grpc/_adapter/_low.py
@@ -78,6 +78,9 @@ class Call(_types.Call):
def peer(self):
return self.call.peer()
+ def set_credentials(self, creds):
+ return self.call.set_credentials(creds)
+
class Channel(_types.Channel):
diff --git a/src/python/grpcio/grpc/_links/_constants.py b/src/python/grpcio/grpc/_links/_constants.py
new file mode 100644
index 0000000000..117fc5a639
--- /dev/null
+++ b/src/python/grpcio/grpc/_links/_constants.py
@@ -0,0 +1,42 @@
+# 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.
+
+"""Constants for use within this package."""
+
+from grpc._adapter import _intermediary_low
+from grpc.beta import interfaces as beta_interfaces
+
+LOW_STATUS_CODE_TO_HIGH_STATUS_CODE = {
+ low: high for low, high in zip(
+ _intermediary_low.Code, beta_interfaces.StatusCode)
+}
+
+HIGH_STATUS_CODE_TO_LOW_STATUS_CODE = {
+ high: low for low, high in LOW_STATUS_CODE_TO_HIGH_STATUS_CODE.items()
+}
diff --git a/src/python/grpcio/grpc/_links/invocation.py b/src/python/grpcio/grpc/_links/invocation.py
index 1676fe7941..fecb550ae0 100644
--- a/src/python/grpcio/grpc/_links/invocation.py
+++ b/src/python/grpcio/grpc/_links/invocation.py
@@ -36,6 +36,7 @@ import threading
import time
from grpc._adapter import _intermediary_low
+from grpc._links import _constants
from grpc.framework.foundation import activated
from grpc.framework.foundation import logging_pool
from grpc.framework.foundation import relay
@@ -168,14 +169,17 @@ class _Kernel(object):
termination = links.Ticket.Termination.CANCELLATION
elif event.status.code is _intermediary_low.Code.DEADLINE_EXCEEDED:
termination = links.Ticket.Termination.EXPIRATION
+ elif event.status.code is _intermediary_low.Code.UNIMPLEMENTED:
+ termination = links.Ticket.Termination.REMOTE_FAILURE
elif event.status.code is _intermediary_low.Code.UNKNOWN:
termination = links.Ticket.Termination.LOCAL_FAILURE
else:
termination = links.Ticket.Termination.TRANSMISSION_FAILURE
+ code = _constants.LOW_STATUS_CODE_TO_HIGH_STATUS_CODE[event.status.code]
ticket = links.Ticket(
operation_id, rpc_state.sequence_number, None, None, None, None, None,
- None, None, event.metadata, event.status.code, event.status.details,
- termination, None)
+ None, None, event.metadata, code, event.status.details, termination,
+ None)
rpc_state.sequence_number += 1
self._relay.add_value(ticket)
diff --git a/src/python/grpcio/grpc/_links/service.py b/src/python/grpcio/grpc/_links/service.py
index 94e7cfc716..34d3b262c9 100644
--- a/src/python/grpcio/grpc/_links/service.py
+++ b/src/python/grpcio/grpc/_links/service.py
@@ -36,6 +36,7 @@ import threading
import time
from grpc._adapter import _intermediary_low
+from grpc._links import _constants
from grpc.framework.foundation import logging_pool
from grpc.framework.foundation import relay
from grpc.framework.interfaces.links import links
@@ -122,13 +123,13 @@ def _metadatafy(call, metadata):
call.add_metadata(metadata_key, metadata_value)
-def _status(termination_kind, code, details):
- effective_details = b'' if details is None else details
- if code is None:
- effective_code = _TERMINATION_KIND_TO_CODE[termination_kind]
+def _status(termination_kind, high_code, details):
+ low_details = b'' if details is None else details
+ if high_code is None:
+ low_code = _TERMINATION_KIND_TO_CODE[termination_kind]
else:
- effective_code = code
- return _intermediary_low.Status(effective_code, effective_details)
+ low_code = _constants.HIGH_STATUS_CODE_TO_LOW_STATUS_CODE[high_code]
+ return _intermediary_low.Status(low_code, low_details)
class _Kernel(object):
diff --git a/src/python/grpcio/grpc/beta/_server.py b/src/python/grpcio/grpc/beta/_server.py
index 4e46ffd17f..ebf91d80ab 100644
--- a/src/python/grpcio/grpc/beta/_server.py
+++ b/src/python/grpcio/grpc/beta/_server.py
@@ -32,9 +32,11 @@
import threading
from grpc._links import service
+from grpc.beta import interfaces
from grpc.framework.core import implementations as _core_implementations
from grpc.framework.crust import implementations as _crust_implementations
from grpc.framework.foundation import logging_pool
+from grpc.framework.interfaces.base import base
from grpc.framework.interfaces.links import utilities
_DEFAULT_POOL_SIZE = 8
@@ -42,6 +44,23 @@ _DEFAULT_TIMEOUT = 300
_MAXIMUM_TIMEOUT = 24 * 60 * 60
+class _GRPCServicer(base.Servicer):
+
+ def __init__(self, delegate):
+ self._delegate = delegate
+
+ def service(self, group, method, context, output_operator):
+ try:
+ return self._delegate.service(group, method, context, output_operator)
+ except base.NoSuchMethodError as e:
+ if e.code is None and e.details is None:
+ raise base.NoSuchMethodError(
+ interfaces.StatusCode.UNIMPLEMENTED,
+ b'Method "%s" of service "%s" not implemented!' % (method, group))
+ else:
+ raise
+
+
def _disassemble(grpc_link, end_link, pool, event, grace):
grpc_link.begin_stop()
end_link.stop(grace).wait()
@@ -99,8 +118,9 @@ def server(
service_thread_pool = thread_pool
assembly_thread_pool = None
- servicer = _crust_implementations.servicer(
- implementations, multi_implementation, service_thread_pool)
+ servicer = _GRPCServicer(
+ _crust_implementations.servicer(
+ implementations, multi_implementation, service_thread_pool))
grpc_link = service.service_link(request_deserializers, response_serializers)
diff --git a/src/python/grpcio/grpc/beta/interfaces.py b/src/python/grpcio/grpc/beta/interfaces.py
new file mode 100644
index 0000000000..25e6a9c66b
--- /dev/null
+++ b/src/python/grpcio/grpc/beta/interfaces.py
@@ -0,0 +1,54 @@
+# 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.
+
+"""Constants and interfaces of the Beta API of gRPC Python."""
+
+import enum
+
+
+@enum.unique
+class StatusCode(enum.Enum):
+ """Mirrors grpc_status_code in the C core."""
+ OK = 0
+ CANCELLED = 1
+ UNKNOWN = 2
+ INVALID_ARGUMENT = 3
+ DEADLINE_EXCEEDED = 4
+ NOT_FOUND = 5
+ ALREADY_EXISTS = 6
+ PERMISSION_DENIED = 7
+ RESOURCE_EXHAUSTED = 8
+ FAILED_PRECONDITION = 9
+ ABORTED = 10
+ OUT_OF_RANGE = 11
+ UNIMPLEMENTED = 12
+ INTERNAL = 13
+ UNAVAILABLE = 14
+ DATA_LOSS = 15
+ UNAUTHENTICATED = 16
diff --git a/src/python/grpcio/grpc/framework/core/_constants.py b/src/python/grpcio/grpc/framework/core/_constants.py
index d3be3a4c4a..0f47cb48e0 100644
--- a/src/python/grpcio/grpc/framework/core/_constants.py
+++ b/src/python/grpcio/grpc/framework/core/_constants.py
@@ -44,14 +44,15 @@ TICKET_SUBSCRIPTION_FOR_BASE_SUBSCRIPTION_KIND = {
# ticket should be sent to the other side in the event of such an
# outcome.
ABORTION_OUTCOME_TO_TICKET_TERMINATION = {
- base.Outcome.CANCELLED: links.Ticket.Termination.CANCELLATION,
- base.Outcome.EXPIRED: links.Ticket.Termination.EXPIRATION,
- base.Outcome.LOCAL_SHUTDOWN: links.Ticket.Termination.SHUTDOWN,
- base.Outcome.REMOTE_SHUTDOWN: None,
- base.Outcome.RECEPTION_FAILURE: links.Ticket.Termination.RECEPTION_FAILURE,
- base.Outcome.TRANSMISSION_FAILURE: None,
- base.Outcome.LOCAL_FAILURE: links.Ticket.Termination.LOCAL_FAILURE,
- base.Outcome.REMOTE_FAILURE: links.Ticket.Termination.REMOTE_FAILURE,
+ base.Outcome.Kind.CANCELLED: links.Ticket.Termination.CANCELLATION,
+ base.Outcome.Kind.EXPIRED: links.Ticket.Termination.EXPIRATION,
+ base.Outcome.Kind.LOCAL_SHUTDOWN: links.Ticket.Termination.SHUTDOWN,
+ base.Outcome.Kind.REMOTE_SHUTDOWN: None,
+ base.Outcome.Kind.RECEPTION_FAILURE:
+ links.Ticket.Termination.RECEPTION_FAILURE,
+ base.Outcome.Kind.TRANSMISSION_FAILURE: None,
+ base.Outcome.Kind.LOCAL_FAILURE: links.Ticket.Termination.LOCAL_FAILURE,
+ base.Outcome.Kind.REMOTE_FAILURE: links.Ticket.Termination.REMOTE_FAILURE,
}
INTERNAL_ERROR_LOG_MESSAGE = ':-( RPC Framework (Core) internal error! )-:'
diff --git a/src/python/grpcio/grpc/framework/core/_context.py b/src/python/grpcio/grpc/framework/core/_context.py
index 76b3534530..a346e9d478 100644
--- a/src/python/grpcio/grpc/framework/core/_context.py
+++ b/src/python/grpcio/grpc/framework/core/_context.py
@@ -33,6 +33,7 @@ import time
# _interfaces is referenced from specification in this module.
from grpc.framework.core import _interfaces # pylint: disable=unused-import
+from grpc.framework.core import _utilities
from grpc.framework.interfaces.base import base
@@ -56,11 +57,12 @@ class OperationContext(base.OperationContext):
self._transmission_manager = transmission_manager
self._expiration_manager = expiration_manager
- def _abort(self, outcome):
+ def _abort(self, outcome_kind):
with self._lock:
if self._termination_manager.outcome is None:
+ outcome = _utilities.Outcome(outcome_kind, None, None)
self._termination_manager.abort(outcome)
- self._transmission_manager.abort(outcome, None, None)
+ self._transmission_manager.abort(outcome)
self._expiration_manager.terminate()
def outcome(self):
@@ -85,8 +87,8 @@ class OperationContext(base.OperationContext):
def cancel(self):
"""See base.OperationContext.cancel for specification."""
- self._abort(base.Outcome.CANCELLED)
+ self._abort(base.Outcome.Kind.CANCELLED)
def fail(self, exception):
"""See base.OperationContext.fail for specification."""
- self._abort(base.Outcome.LOCAL_FAILURE)
+ self._abort(base.Outcome.Kind.LOCAL_FAILURE)
diff --git a/src/python/grpcio/grpc/framework/core/_emission.py b/src/python/grpcio/grpc/framework/core/_emission.py
index 2d7b2e2f10..8ab59dc3e5 100644
--- a/src/python/grpcio/grpc/framework/core/_emission.py
+++ b/src/python/grpcio/grpc/framework/core/_emission.py
@@ -30,6 +30,7 @@
"""State and behavior for handling emitted values."""
from grpc.framework.core import _interfaces
+from grpc.framework.core import _utilities
from grpc.framework.interfaces.base import base
@@ -81,9 +82,10 @@ class EmissionManager(_interfaces.EmissionManager):
payload_present and self._completion_seen or
completion_present and self._completion_seen or
allowance_present and allowance <= 0):
- self._termination_manager.abort(base.Outcome.LOCAL_FAILURE)
- self._transmission_manager.abort(
- base.Outcome.LOCAL_FAILURE, None, None)
+ outcome = _utilities.Outcome(
+ base.Outcome.Kind.LOCAL_FAILURE, None, None)
+ self._termination_manager.abort(outcome)
+ self._transmission_manager.abort(outcome)
self._expiration_manager.terminate()
else:
self._initial_metadata_seen |= initial_metadata_present
diff --git a/src/python/grpcio/grpc/framework/core/_end.py b/src/python/grpcio/grpc/framework/core/_end.py
index f57cde4e58..336e9c21fd 100644
--- a/src/python/grpcio/grpc/framework/core/_end.py
+++ b/src/python/grpcio/grpc/framework/core/_end.py
@@ -69,7 +69,7 @@ class _Cycle(object):
def _abort(operations):
for operation in operations:
- operation.abort(base.Outcome.LOCAL_SHUTDOWN)
+ operation.abort(base.Outcome.Kind.LOCAL_SHUTDOWN)
def _cancel_futures(futures):
@@ -90,19 +90,19 @@ def _termination_action(lock, stats, operation_id, cycle):
Args:
lock: A lock to hold during the termination action.
- states: A mapping from base.Outcome values to integers to increment with
- the outcome given to the termination action.
+ stats: A mapping from base.Outcome.Kind values to integers to increment
+ with the outcome kind given to the termination action.
operation_id: The operation ID for the termination action.
cycle: A _Cycle value to be updated during the termination action.
Returns:
- A callable that takes an operation outcome as its sole parameter and that
- should be used as the termination action for the operation associated
- with the given operation ID.
+ A callable that takes an operation outcome kind as its sole parameter and
+ that should be used as the termination action for the operation
+ associated with the given operation ID.
"""
- def termination_action(outcome):
+ def termination_action(outcome_kind):
with lock:
- stats[outcome] += 1
+ stats[outcome_kind] += 1
cycle.operations.pop(operation_id, None)
if not cycle.operations:
for action in cycle.idle_actions:
@@ -127,7 +127,7 @@ class _End(End):
self._lock = threading.Condition()
self._servicer_package = servicer_package
- self._stats = {outcome: 0 for outcome in base.Outcome}
+ self._stats = {outcome_kind: 0 for outcome_kind in base.Outcome.Kind}
self._mate = None
diff --git a/src/python/grpcio/grpc/framework/core/_expiration.py b/src/python/grpcio/grpc/framework/core/_expiration.py
index d8690b3a02..ded0ab6bce 100644
--- a/src/python/grpcio/grpc/framework/core/_expiration.py
+++ b/src/python/grpcio/grpc/framework/core/_expiration.py
@@ -32,6 +32,7 @@
import time
from grpc.framework.core import _interfaces
+from grpc.framework.core import _utilities
from grpc.framework.foundation import later
from grpc.framework.interfaces.base import base
@@ -73,7 +74,8 @@ class _ExpirationManager(_interfaces.ExpirationManager):
if self._future is not None and index == self._index:
self._future = None
self._termination_manager.expire()
- self._transmission_manager.abort(base.Outcome.EXPIRED, None, None)
+ self._transmission_manager.abort(
+ _utilities.Outcome(base.Outcome.Kind.EXPIRED, None, None))
return expire
def start(self):
diff --git a/src/python/grpcio/grpc/framework/core/_ingestion.py b/src/python/grpcio/grpc/framework/core/_ingestion.py
index 7b8127f3fc..9a7959a2dd 100644
--- a/src/python/grpcio/grpc/framework/core/_ingestion.py
+++ b/src/python/grpcio/grpc/framework/core/_ingestion.py
@@ -35,6 +35,7 @@ import enum
from grpc.framework.core import _constants
from grpc.framework.core import _interfaces
+from grpc.framework.core import _utilities
from grpc.framework.foundation import abandonment
from grpc.framework.foundation import callable_util
from grpc.framework.interfaces.base import base
@@ -46,7 +47,7 @@ _INGESTION_EXCEPTION_LOG_MESSAGE = 'Exception during ingestion!'
class _SubscriptionCreation(
collections.namedtuple(
'_SubscriptionCreation',
- ('kind', 'subscription', 'code', 'message',))):
+ ('kind', 'subscription', 'code', 'details',))):
"""A sum type for the outcome of ingestion initialization.
Attributes:
@@ -56,7 +57,7 @@ class _SubscriptionCreation(
code: A code value to be sent to the other side of the operation along with
an indication that the operation is being aborted due to an error on the
remote side of the operation. Only present if kind is Kind.REMOTE_ERROR.
- message: A message value to be sent to the other side of the operation
+ details: A details value to be sent to the other side of the operation
along with an indication that the operation is being aborted due to an
error on the remote side of the operation. Only present if kind is
Kind.REMOTE_ERROR.
@@ -114,7 +115,7 @@ class _ServiceSubscriptionCreator(_SubscriptionCreator):
group, method, self._operation_context, self._output_operator)
except base.NoSuchMethodError as e:
return _SubscriptionCreation(
- _SubscriptionCreation.Kind.REMOTE_ERROR, None, e.code, e.message)
+ _SubscriptionCreation.Kind.REMOTE_ERROR, None, e.code, e.details)
except abandonment.Abandoned:
return _SubscriptionCreation(
_SubscriptionCreation.Kind.ABANDONED, None, None, None)
@@ -190,11 +191,13 @@ class _IngestionManager(_interfaces.IngestionManager):
self._pending_payloads = None
self._pending_completion = None
- def _abort_and_notify(self, outcome, code, message):
+ def _abort_and_notify(self, outcome_kind, code, details):
self._abort_internal_only()
- self._termination_manager.abort(outcome)
- self._transmission_manager.abort(outcome, code, message)
- self._expiration_manager.terminate()
+ if self._termination_manager.outcome is None:
+ outcome = _utilities.Outcome(outcome_kind, code, details)
+ self._termination_manager.abort(outcome)
+ self._transmission_manager.abort(outcome)
+ self._expiration_manager.terminate()
def _operator_next(self):
"""Computes the next step for full-subscription ingestion.
@@ -250,12 +253,13 @@ class _IngestionManager(_interfaces.IngestionManager):
else:
with self._lock:
if self._termination_manager.outcome is None:
- self._abort_and_notify(base.Outcome.LOCAL_FAILURE, None, None)
+ self._abort_and_notify(
+ base.Outcome.Kind.LOCAL_FAILURE, None, None)
return
else:
with self._lock:
if self._termination_manager.outcome is None:
- self._abort_and_notify(base.Outcome.LOCAL_FAILURE, None, None)
+ self._abort_and_notify(base.Outcome.Kind.LOCAL_FAILURE, None, None)
return
def _operator_post_create(self, subscription):
@@ -279,17 +283,18 @@ class _IngestionManager(_interfaces.IngestionManager):
if outcome.return_value is None:
with self._lock:
if self._termination_manager.outcome is None:
- self._abort_and_notify(base.Outcome.LOCAL_FAILURE, None, None)
+ self._abort_and_notify(base.Outcome.Kind.LOCAL_FAILURE, None, None)
elif outcome.return_value.kind is _SubscriptionCreation.Kind.ABANDONED:
with self._lock:
if self._termination_manager.outcome is None:
- self._abort_and_notify(base.Outcome.LOCAL_FAILURE, None, None)
+ self._abort_and_notify(base.Outcome.Kind.LOCAL_FAILURE, None, None)
elif outcome.return_value.kind is _SubscriptionCreation.Kind.REMOTE_ERROR:
code = outcome.return_value.code
- message = outcome.return_value.message
+ details = outcome.return_value.details
with self._lock:
if self._termination_manager.outcome is None:
- self._abort_and_notify(base.Outcome.REMOTE_FAILURE, code, message)
+ self._abort_and_notify(
+ base.Outcome.Kind.REMOTE_FAILURE, code, details)
elif outcome.return_value.subscription.kind is base.Subscription.Kind.FULL:
self._operator_post_create(outcome.return_value.subscription)
else:
diff --git a/src/python/grpcio/grpc/framework/core/_interfaces.py b/src/python/grpcio/grpc/framework/core/_interfaces.py
index deb5f34f9b..2a534cb7e7 100644
--- a/src/python/grpcio/grpc/framework/core/_interfaces.py
+++ b/src/python/grpcio/grpc/framework/core/_interfaces.py
@@ -50,13 +50,13 @@ class TerminationManager(object):
If the operation has already terminated the callback will not be called.
Args:
- callback: A callable that will be passed an interfaces.Outcome value.
+ callback: A callable that will be passed a base.Outcome value.
Returns:
None if the operation has not yet terminated and the passed callback will
- be called when it does, or a base.Outcome value describing the operation
- termination if the operation has terminated and the callback will not be
- called as a result of this method call.
+ be called when it does, or a base.Outcome value describing the
+ operation termination if the operation has terminated and the callback
+ will not be called as a result of this method call.
"""
raise NotImplementedError()
@@ -76,8 +76,13 @@ class TerminationManager(object):
raise NotImplementedError()
@abc.abstractmethod
- def reception_complete(self):
- """Indicates that reception from the other side is complete."""
+ def reception_complete(self, code, details):
+ """Indicates that reception from the other side is complete.
+
+ Args:
+ code: An application-specific code value.
+ details: An application-specific details value.
+ """
raise NotImplementedError()
@abc.abstractmethod
@@ -95,7 +100,7 @@ class TerminationManager(object):
"""Indicates that the operation must abort for the indicated reason.
Args:
- outcome: An interfaces.Outcome indicating operation abortion.
+ outcome: A base.Outcome indicating operation abortion.
"""
raise NotImplementedError()
@@ -155,19 +160,13 @@ class TransmissionManager(object):
raise NotImplementedError()
@abc.abstractmethod
- def abort(self, outcome, code, message):
+ def abort(self, outcome):
"""Indicates that the operation has aborted.
Args:
- outcome: An interfaces.Outcome for the operation. If None, indicates that
- the operation abortion should not be communicated to the other side of
- the operation.
- code: A code value to communicate to the other side of the operation
- along with indication of operation abortion. May be None, and has no
- effect if outcome is None.
- message: A message value to communicate to the other side of the
- operation along with indication of operation abortion. May be None, and
- has no effect if outcome is None.
+ outcome: A base.Outcome for the operation. If None, indicates that the
+ operation abortion should not be communicated to the other side of the
+ operation.
"""
raise NotImplementedError()
@@ -279,8 +278,7 @@ class ReceptionManager(object):
"""Handle a ticket from the other side of the operation.
Args:
- ticket: An interfaces.BackToFrontTicket or interfaces.FrontToBackTicket
- appropriate to this end of the operation and this object.
+ ticket: A links.Ticket for the operation.
"""
raise NotImplementedError()
@@ -305,10 +303,10 @@ class Operation(object):
raise NotImplementedError()
@abc.abstractmethod
- def abort(self, outcome):
+ def abort(self, outcome_kind):
"""Aborts the operation.
Args:
- outcome: A base.Outcome value indicating operation abortion.
+ outcome_kind: A base.Outcome.Kind value indicating operation abortion.
"""
raise NotImplementedError()
diff --git a/src/python/grpcio/grpc/framework/core/_operation.py b/src/python/grpcio/grpc/framework/core/_operation.py
index cc873c03f9..f5679d0356 100644
--- a/src/python/grpcio/grpc/framework/core/_operation.py
+++ b/src/python/grpcio/grpc/framework/core/_operation.py
@@ -31,7 +31,6 @@
import threading
-# _utilities is referenced from specification in this module.
from grpc.framework.core import _context
from grpc.framework.core import _emission
from grpc.framework.core import _expiration
@@ -40,7 +39,7 @@ from grpc.framework.core import _interfaces
from grpc.framework.core import _reception
from grpc.framework.core import _termination
from grpc.framework.core import _transmission
-from grpc.framework.core import _utilities # pylint: disable=unused-import
+from grpc.framework.core import _utilities
class _EasyOperation(_interfaces.Operation):
@@ -75,11 +74,12 @@ class _EasyOperation(_interfaces.Operation):
with self._lock:
self._reception_manager.receive_ticket(ticket)
- def abort(self, outcome):
+ def abort(self, outcome_kind):
with self._lock:
if self._termination_manager.outcome is None:
+ outcome = _utilities.Outcome(outcome_kind, None, None)
self._termination_manager.abort(outcome)
- self._transmission_manager.abort(outcome, None, None)
+ self._transmission_manager.abort(outcome)
self._expiration_manager.terminate()
diff --git a/src/python/grpcio/grpc/framework/core/_reception.py b/src/python/grpcio/grpc/framework/core/_reception.py
index 1cebe3874b..d374cf0c8c 100644
--- a/src/python/grpcio/grpc/framework/core/_reception.py
+++ b/src/python/grpcio/grpc/framework/core/_reception.py
@@ -30,21 +30,26 @@
"""State and behavior for ticket reception."""
from grpc.framework.core import _interfaces
+from grpc.framework.core import _utilities
from grpc.framework.interfaces.base import base
from grpc.framework.interfaces.base import utilities
from grpc.framework.interfaces.links import links
-_REMOTE_TICKET_TERMINATION_TO_LOCAL_OUTCOME = {
- links.Ticket.Termination.CANCELLATION: base.Outcome.CANCELLED,
- links.Ticket.Termination.EXPIRATION: base.Outcome.EXPIRED,
- links.Ticket.Termination.SHUTDOWN: base.Outcome.REMOTE_SHUTDOWN,
- links.Ticket.Termination.RECEPTION_FAILURE: base.Outcome.RECEPTION_FAILURE,
+_REMOTE_TICKET_TERMINATION_TO_LOCAL_OUTCOME_KIND = {
+ links.Ticket.Termination.CANCELLATION: base.Outcome.Kind.CANCELLED,
+ links.Ticket.Termination.EXPIRATION: base.Outcome.Kind.EXPIRED,
+ links.Ticket.Termination.SHUTDOWN: base.Outcome.Kind.REMOTE_SHUTDOWN,
+ links.Ticket.Termination.RECEPTION_FAILURE:
+ base.Outcome.Kind.RECEPTION_FAILURE,
links.Ticket.Termination.TRANSMISSION_FAILURE:
- base.Outcome.TRANSMISSION_FAILURE,
- links.Ticket.Termination.LOCAL_FAILURE: base.Outcome.REMOTE_FAILURE,
- links.Ticket.Termination.REMOTE_FAILURE: base.Outcome.LOCAL_FAILURE,
+ base.Outcome.Kind.TRANSMISSION_FAILURE,
+ links.Ticket.Termination.LOCAL_FAILURE: base.Outcome.Kind.REMOTE_FAILURE,
+ links.Ticket.Termination.REMOTE_FAILURE: base.Outcome.Kind.LOCAL_FAILURE,
}
+_RECEPTION_FAILURE_OUTCOME = _utilities.Outcome(
+ base.Outcome.Kind.RECEPTION_FAILURE, None, None)
+
class ReceptionManager(_interfaces.ReceptionManager):
"""A ReceptionManager based around a _Receiver passed to it."""
@@ -73,7 +78,7 @@ class ReceptionManager(_interfaces.ReceptionManager):
self._aborted = True
if self._termination_manager.outcome is None:
self._termination_manager.abort(outcome)
- self._transmission_manager.abort(None, None, None)
+ self._transmission_manager.abort(None)
self._expiration_manager.terminate()
def _sequence_failure(self, ticket):
@@ -102,6 +107,7 @@ class ReceptionManager(_interfaces.ReceptionManager):
else:
completion = utilities.completion(
ticket.terminal_metadata, ticket.code, ticket.message)
+ self._termination_manager.reception_complete(ticket.code, ticket.message)
self._ingestion_manager.advance(
ticket.initial_metadata, ticket.payload, completion, ticket.allowance)
if ticket.allowance is not None:
@@ -129,10 +135,12 @@ class ReceptionManager(_interfaces.ReceptionManager):
if self._aborted:
return
elif self._sequence_failure(ticket):
- self._abort(base.Outcome.RECEPTION_FAILURE)
+ self._abort(_RECEPTION_FAILURE_OUTCOME)
elif ticket.termination not in (None, links.Ticket.Termination.COMPLETION):
- outcome = _REMOTE_TICKET_TERMINATION_TO_LOCAL_OUTCOME[ticket.termination]
- self._abort(outcome)
+ outcome_kind = _REMOTE_TICKET_TERMINATION_TO_LOCAL_OUTCOME_KIND[
+ ticket.termination]
+ self._abort(
+ _utilities.Outcome(outcome_kind, ticket.code, ticket.message))
elif ticket.sequence_number == self._lowest_unseen_sequence_number:
self._process(ticket)
else:
diff --git a/src/python/grpcio/grpc/framework/core/_termination.py b/src/python/grpcio/grpc/framework/core/_termination.py
index ad9f6123d8..bdb9147e5b 100644
--- a/src/python/grpcio/grpc/framework/core/_termination.py
+++ b/src/python/grpcio/grpc/framework/core/_termination.py
@@ -33,6 +33,7 @@ import abc
from grpc.framework.core import _constants
from grpc.framework.core import _interfaces
+from grpc.framework.core import _utilities
from grpc.framework.foundation import callable_util
from grpc.framework.interfaces.base import base
@@ -74,7 +75,8 @@ class _TerminationManager(TerminationManager):
predicate: One of _invocation_completion_predicate or
_service_completion_predicate to be used to determine when the operation
has completed.
- action: A behavior to pass the operation outcome on operation termination.
+ action: A behavior to pass the operation outcome's kind on operation
+ termination.
pool: A thread pool.
"""
self._predicate = predicate
@@ -82,14 +84,19 @@ class _TerminationManager(TerminationManager):
self._pool = pool
self._expiration_manager = None
- self.outcome = None
self._callbacks = []
+ self._code = None
+ self._details = None
self._emission_complete = False
self._transmission_complete = False
self._reception_complete = False
self._ingestion_complete = False
+ # The None-ness of outcome is the operation-wide record of whether and how
+ # the operation has terminated.
+ self.outcome = None
+
def set_expiration_manager(self, expiration_manager):
self._expiration_manager = expiration_manager
@@ -106,8 +113,10 @@ class _TerminationManager(TerminationManager):
act = callable_util.with_exceptions_logged(
self._action, _constants.INTERNAL_ERROR_LOG_MESSAGE)
- if outcome is base.Outcome.LOCAL_FAILURE:
- self._pool.submit(act, outcome)
+ # TODO(issue 3202): Don't call the local application's callbacks if it has
+ # previously shown a programming defect.
+ if False and outcome.kind is base.Outcome.Kind.LOCAL_FAILURE:
+ self._pool.submit(act, base.Outcome.Kind.LOCAL_FAILURE)
else:
def call_callbacks_and_act(callbacks, outcome):
for callback in callbacks:
@@ -115,9 +124,11 @@ class _TerminationManager(TerminationManager):
callback, _constants.TERMINATION_CALLBACK_EXCEPTION_LOG_MESSAGE,
outcome)
if callback_outcome.exception is not None:
- outcome = base.Outcome.LOCAL_FAILURE
+ act_outcome_kind = base.Outcome.Kind.LOCAL_FAILURE
break
- act(outcome)
+ else:
+ act_outcome_kind = outcome.kind
+ act(act_outcome_kind)
self._pool.submit(
callable_util.with_exceptions_logged(
@@ -132,7 +143,9 @@ class _TerminationManager(TerminationManager):
if self._predicate(
self._emission_complete, self._transmission_complete,
self._reception_complete, self._ingestion_complete):
- self._terminate_and_notify(base.Outcome.COMPLETED)
+ self._terminate_and_notify(
+ _utilities.Outcome(
+ base.Outcome.Kind.COMPLETED, self._code, self._details))
return True
else:
return False
@@ -163,10 +176,12 @@ class _TerminationManager(TerminationManager):
else:
return False
- def reception_complete(self):
+ def reception_complete(self, code, details):
"""See superclass method for specification."""
if self.outcome is None:
self._reception_complete = True
+ self._code = code
+ self._details = details
self._perhaps_complete()
def ingestion_complete(self):
@@ -177,7 +192,8 @@ class _TerminationManager(TerminationManager):
def expire(self):
"""See _interfaces.TerminationManager.expire for specification."""
- self._terminate_internal_only(base.Outcome.EXPIRED)
+ self._terminate_internal_only(
+ _utilities.Outcome(base.Outcome.Kind.EXPIRED, None, None))
def abort(self, outcome):
"""See _interfaces.TerminationManager.abort for specification."""
diff --git a/src/python/grpcio/grpc/framework/core/_transmission.py b/src/python/grpcio/grpc/framework/core/_transmission.py
index efef87dd4c..8f852cfe9f 100644
--- a/src/python/grpcio/grpc/framework/core/_transmission.py
+++ b/src/python/grpcio/grpc/framework/core/_transmission.py
@@ -29,14 +29,21 @@
"""State and behavior for ticket transmission during an operation."""
+import collections
+import enum
+
from grpc.framework.core import _constants
from grpc.framework.core import _interfaces
+from grpc.framework.core import _utilities
from grpc.framework.foundation import callable_util
from grpc.framework.interfaces.base import base
from grpc.framework.interfaces.links import links
_TRANSMISSION_EXCEPTION_LOG_MESSAGE = 'Exception during transmission!'
+_TRANSMISSION_FAILURE_OUTCOME = _utilities.Outcome(
+ base.Outcome.Kind.TRANSMISSION_FAILURE, None, None)
+
def _explode_completion(completion):
if completion is None:
@@ -47,6 +54,31 @@ def _explode_completion(completion):
links.Ticket.Termination.COMPLETION)
+class _Abort(
+ collections.namedtuple(
+ '_Abort', ('kind', 'termination', 'code', 'details',))):
+ """Tracks whether the operation aborted and what is to be done about it.
+
+ Attributes:
+ kind: A Kind value describing the overall kind of the _Abort.
+ termination: A links.Ticket.Termination value to be sent to the other side
+ of the operation. Only valid if kind is Kind.ABORTED_NOTIFY_NEEDED.
+ code: A code value to be sent to the other side of the operation. Only
+ valid if kind is Kind.ABORTED_NOTIFY_NEEDED.
+ details: A details value to be sent to the other side of the operation.
+ Only valid if kind is Kind.ABORTED_NOTIFY_NEEDED.
+ """
+
+ @enum.unique
+ class Kind(enum.Enum):
+ NOT_ABORTED = 'not aborted'
+ ABORTED_NOTIFY_NEEDED = 'aborted notify needed'
+ ABORTED_NO_NOTIFY = 'aborted no notify'
+
+_NOT_ABORTED = _Abort(_Abort.Kind.NOT_ABORTED, None, None, None)
+_ABORTED_NO_NOTIFY = _Abort(_Abort.Kind.ABORTED_NO_NOTIFY, None, None, None)
+
+
class TransmissionManager(_interfaces.TransmissionManager):
"""An _interfaces.TransmissionManager that sends links.Tickets."""
@@ -79,8 +111,7 @@ class TransmissionManager(_interfaces.TransmissionManager):
self._initial_metadata = None
self._payloads = []
self._completion = None
- self._aborted = False
- self._abortion_outcome = None
+ self._abort = _NOT_ABORTED
self._transmitting = False
def set_expiration_manager(self, expiration_manager):
@@ -94,24 +125,15 @@ class TransmissionManager(_interfaces.TransmissionManager):
A links.Ticket to be sent to the other side of the operation or None if
there is nothing to be sent at this time.
"""
- if self._aborted:
- if self._abortion_outcome is None:
- return None
- else:
- termination = _constants.ABORTION_OUTCOME_TO_TICKET_TERMINATION[
- self._abortion_outcome]
- if termination is None:
- return None
- else:
- self._abortion_outcome = None
- if self._completion is None:
- code, message = None, None
- else:
- code, message = self._completion.code, self._completion.message
- return links.Ticket(
- self._operation_id, self._lowest_unused_sequence_number, None,
- None, None, None, None, None, None, None, code, message,
- termination, None)
+ if self._abort.kind is _Abort.Kind.ABORTED_NO_NOTIFY:
+ return None
+ elif self._abort.kind is _Abort.Kind.ABORTED_NOTIFY_NEEDED:
+ termination = self._abort.termination
+ code, details = self._abort.code, self._abort.details
+ self._abort = _ABORTED_NO_NOTIFY
+ return links.Ticket(
+ self._operation_id, self._lowest_unused_sequence_number, None, None,
+ None, None, None, None, None, None, code, details, termination, None)
action = False
# TODO(nathaniel): Support other subscriptions.
@@ -174,8 +196,9 @@ class TransmissionManager(_interfaces.TransmissionManager):
return
else:
with self._lock:
+ self._abort = _ABORTED_NO_NOTIFY
if self._termination_manager.outcome is None:
- self._termination_manager.abort(base.Outcome.TRANSMISSION_FAILURE)
+ self._termination_manager.abort(_TRANSMISSION_FAILURE_OUTCOME)
self._expiration_manager.terminate()
return
@@ -201,6 +224,9 @@ class TransmissionManager(_interfaces.TransmissionManager):
def advance(self, initial_metadata, payload, completion, allowance):
"""See _interfaces.TransmissionManager.advance for specification."""
+ if self._abort.kind is not _Abort.Kind.NOT_ABORTED:
+ return
+
effective_initial_metadata = initial_metadata
effective_payload = payload
effective_completion = completion
@@ -246,7 +272,9 @@ class TransmissionManager(_interfaces.TransmissionManager):
def timeout(self, timeout):
"""See _interfaces.TransmissionManager.timeout for specification."""
- if self._transmitting:
+ if self._abort.kind is not _Abort.Kind.NOT_ABORTED:
+ return
+ elif self._transmitting:
self._timeout = timeout
else:
ticket = links.Ticket(
@@ -257,7 +285,9 @@ class TransmissionManager(_interfaces.TransmissionManager):
def allowance(self, allowance):
"""See _interfaces.TransmissionManager.allowance for specification."""
- if self._transmitting or not self._payloads:
+ if self._abort.kind is not _Abort.Kind.NOT_ABORTED:
+ return
+ elif self._transmitting or not self._payloads:
self._remote_allowance += allowance
else:
self._remote_allowance += allowance - 1
@@ -281,22 +311,24 @@ class TransmissionManager(_interfaces.TransmissionManager):
self._remote_complete = True
self._local_allowance = 0
- def abort(self, outcome, code, message):
+ def abort(self, outcome):
"""See _interfaces.TransmissionManager.abort for specification."""
- if self._transmitting:
- self._aborted, self._abortion_outcome = True, outcome
- else:
- self._aborted = True
- if outcome is not None:
- termination = _constants.ABORTION_OUTCOME_TO_TICKET_TERMINATION[
- outcome]
- if termination is not None:
- if self._completion is None:
- code, message = None, None
- else:
- code, message = self._completion.code, self._completion.message
+ if self._abort.kind is _Abort.Kind.NOT_ABORTED:
+ if outcome is None:
+ self._abort = _ABORTED_NO_NOTIFY
+ else:
+ termination = _constants.ABORTION_OUTCOME_TO_TICKET_TERMINATION.get(
+ outcome.kind)
+ if termination is None:
+ self._abort = _ABORTED_NO_NOTIFY
+ elif self._transmitting:
+ self._abort = _Abort(
+ _Abort.Kind.ABORTED_NOTIFY_NEEDED, termination, outcome.code,
+ outcome.details)
+ else:
ticket = links.Ticket(
self._operation_id, self._lowest_unused_sequence_number, None,
- None, None, None, None, None, None, None, code, message,
- termination, None)
+ None, None, None, None, None, None, None, outcome.code,
+ outcome.details, termination, None)
self._transmit(ticket)
+ self._abort = _ABORTED_NO_NOTIFY
diff --git a/src/python/grpcio/grpc/framework/core/_utilities.py b/src/python/grpcio/grpc/framework/core/_utilities.py
index 5b0d798751..abedc727e4 100644
--- a/src/python/grpcio/grpc/framework/core/_utilities.py
+++ b/src/python/grpcio/grpc/framework/core/_utilities.py
@@ -31,6 +31,8 @@
import collections
+from grpc.framework.interfaces.base import base
+
class ServicerPackage(
collections.namedtuple(
@@ -44,3 +46,9 @@ class ServicerPackage(
maximum_timeout: A float indicating the maximum length of time in seconds to
allow for an operation.
"""
+
+
+class Outcome(
+ base.Outcome,
+ collections.namedtuple('Outcome', ('kind', 'code', 'details',))):
+ """A trivial implementation of base.Outcome."""
diff --git a/src/python/grpcio/grpc/framework/crust/_calls.py b/src/python/grpcio/grpc/framework/crust/_calls.py
index f9077bedfe..4c6bf16f43 100644
--- a/src/python/grpcio/grpc/framework/crust/_calls.py
+++ b/src/python/grpcio/grpc/framework/crust/_calls.py
@@ -98,7 +98,7 @@ def blocking_unary_unary(
rendezvous, unused_operation_context, unused_outcome = _invoke(
end, group, method, timeout, initial_metadata, payload, True)
if with_call:
- return next(rendezvous, rendezvous)
+ return next(rendezvous), rendezvous
else:
return next(rendezvous)
diff --git a/src/python/grpcio/grpc/framework/crust/_control.py b/src/python/grpcio/grpc/framework/crust/_control.py
index 01de3c15bd..7bddf46a57 100644
--- a/src/python/grpcio/grpc/framework/crust/_control.py
+++ b/src/python/grpcio/grpc/framework/crust/_control.py
@@ -110,30 +110,31 @@ class _Termination(
_NOT_TERMINATED = _Termination(False, None, None)
-_OPERATION_OUTCOME_TO_TERMINATION_CONSTRUCTOR = {
- base.Outcome.COMPLETED: lambda *unused_args: _Termination(True, None, None),
- base.Outcome.CANCELLED: lambda *args: _Termination(
+_OPERATION_OUTCOME_KIND_TO_TERMINATION_CONSTRUCTOR = {
+ base.Outcome.Kind.COMPLETED: lambda *unused_args: _Termination(
+ True, None, None),
+ base.Outcome.Kind.CANCELLED: lambda *args: _Termination(
True, face.Abortion(face.Abortion.Kind.CANCELLED, *args),
face.CancellationError(*args)),
- base.Outcome.EXPIRED: lambda *args: _Termination(
+ base.Outcome.Kind.EXPIRED: lambda *args: _Termination(
True, face.Abortion(face.Abortion.Kind.EXPIRED, *args),
face.ExpirationError(*args)),
- base.Outcome.LOCAL_SHUTDOWN: lambda *args: _Termination(
+ base.Outcome.Kind.LOCAL_SHUTDOWN: lambda *args: _Termination(
True, face.Abortion(face.Abortion.Kind.LOCAL_SHUTDOWN, *args),
face.LocalShutdownError(*args)),
- base.Outcome.REMOTE_SHUTDOWN: lambda *args: _Termination(
+ base.Outcome.Kind.REMOTE_SHUTDOWN: lambda *args: _Termination(
True, face.Abortion(face.Abortion.Kind.REMOTE_SHUTDOWN, *args),
face.RemoteShutdownError(*args)),
- base.Outcome.RECEPTION_FAILURE: lambda *args: _Termination(
+ base.Outcome.Kind.RECEPTION_FAILURE: lambda *args: _Termination(
True, face.Abortion(face.Abortion.Kind.NETWORK_FAILURE, *args),
face.NetworkError(*args)),
- base.Outcome.TRANSMISSION_FAILURE: lambda *args: _Termination(
+ base.Outcome.Kind.TRANSMISSION_FAILURE: lambda *args: _Termination(
True, face.Abortion(face.Abortion.Kind.NETWORK_FAILURE, *args),
face.NetworkError(*args)),
- base.Outcome.LOCAL_FAILURE: lambda *args: _Termination(
+ base.Outcome.Kind.LOCAL_FAILURE: lambda *args: _Termination(
True, face.Abortion(face.Abortion.Kind.LOCAL_FAILURE, *args),
face.LocalError(*args)),
- base.Outcome.REMOTE_FAILURE: lambda *args: _Termination(
+ base.Outcome.Kind.REMOTE_FAILURE: lambda *args: _Termination(
True, face.Abortion(face.Abortion.Kind.REMOTE_FAILURE, *args),
face.RemoteError(*args)),
}
@@ -247,13 +248,17 @@ class Rendezvous(base.Operator, future.Future, stream.Consumer, face.Call):
else:
initial_metadata = self._up_initial_metadata.value
if self._up_completion.kind is _Awaited.Kind.NOT_YET_ARRIVED:
- terminal_metadata, code, details = None, None, None
+ terminal_metadata = None
else:
terminal_metadata = self._up_completion.value.terminal_metadata
+ if outcome.kind is base.Outcome.Kind.COMPLETED:
code = self._up_completion.value.code
details = self._up_completion.value.message
- self._termination = _OPERATION_OUTCOME_TO_TERMINATION_CONSTRUCTOR[
- outcome](initial_metadata, terminal_metadata, code, details)
+ else:
+ code = outcome.code
+ details = outcome.details
+ self._termination = _OPERATION_OUTCOME_KIND_TO_TERMINATION_CONSTRUCTOR[
+ outcome.kind](initial_metadata, terminal_metadata, code, details)
self._condition.notify_all()
diff --git a/src/python/grpcio/grpc/framework/crust/_service.py b/src/python/grpcio/grpc/framework/crust/_service.py
index 2455a58f59..6ff7249e75 100644
--- a/src/python/grpcio/grpc/framework/crust/_service.py
+++ b/src/python/grpcio/grpc/framework/crust/_service.py
@@ -154,7 +154,7 @@ def adapt_multi_method(multi_method, pool):
outcome = operation_context.add_termination_callback(rendezvous.set_outcome)
if outcome is None:
def in_pool():
- request_consumer = multi_method(
+ request_consumer = multi_method.service(
group, method, rendezvous, _ServicerContext(rendezvous))
for request in rendezvous:
request_consumer.consume(request)
diff --git a/src/python/grpcio/grpc/framework/crust/implementations.py b/src/python/grpcio/grpc/framework/crust/implementations.py
index 12f7e79641..d38fab8ba0 100644
--- a/src/python/grpcio/grpc/framework/crust/implementations.py
+++ b/src/python/grpcio/grpc/framework/crust/implementations.py
@@ -49,12 +49,12 @@ class _BaseServicer(base.Servicer):
return adapted_method(output_operator, context)
elif self._adapted_multi_method is not None:
try:
- return self._adapted_multi_method.service(
+ return self._adapted_multi_method(
group, method, output_operator, context)
except face.NoSuchMethodError:
- raise base.NoSuchMethodError()
+ raise base.NoSuchMethodError(None, None)
else:
- raise base.NoSuchMethodError()
+ raise base.NoSuchMethodError(None, None)
class _UnaryUnaryMultiCallable(face.UnaryUnaryMultiCallable):
@@ -315,8 +315,11 @@ def servicer(method_implementations, multi_method_implementation, pool):
"""
adapted_implementations = _adapt_method_implementations(
method_implementations, pool)
- adapted_multi_method_implementation = _service.adapt_multi_method(
- multi_method_implementation, pool)
+ if multi_method_implementation is None:
+ adapted_multi_method_implementation = None
+ else:
+ adapted_multi_method_implementation = _service.adapt_multi_method(
+ multi_method_implementation, pool)
return _BaseServicer(
adapted_implementations, adapted_multi_method_implementation)
diff --git a/src/python/grpcio/grpc/framework/interfaces/base/base.py b/src/python/grpcio/grpc/framework/interfaces/base/base.py
index bc52efb4c5..0d9d6b464e 100644
--- a/src/python/grpcio/grpc/framework/interfaces/base/base.py
+++ b/src/python/grpcio/grpc/framework/interfaces/base/base.py
@@ -40,7 +40,7 @@ applications choose.
# threading is referenced from specification in this module.
import abc
import enum
-import threading
+import threading # pylint: disable=unused-import
# abandonment is referenced from specification in this module.
from grpc.framework.foundation import abandonment # pylint: disable=unused-import
@@ -69,19 +69,30 @@ class NoSuchMethodError(Exception):
self.details = details
-@enum.unique
-class Outcome(enum.Enum):
- """Operation outcomes."""
+class Outcome(object):
+ """The outcome of an operation.
- COMPLETED = 'completed'
- CANCELLED = 'cancelled'
- EXPIRED = 'expired'
- LOCAL_SHUTDOWN = 'local shutdown'
- REMOTE_SHUTDOWN = 'remote shutdown'
- RECEPTION_FAILURE = 'reception failure'
- TRANSMISSION_FAILURE = 'transmission failure'
- LOCAL_FAILURE = 'local failure'
- REMOTE_FAILURE = 'remote failure'
+ Attributes:
+ kind: A Kind value coarsely identifying how the operation terminated.
+ code: An application-specific code value or None if no such value was
+ provided.
+ details: An application-specific details value or None if no such value was
+ provided.
+ """
+
+ @enum.unique
+ class Kind(enum.Enum):
+ """Ways in which an operation can terminate."""
+
+ COMPLETED = 'completed'
+ CANCELLED = 'cancelled'
+ EXPIRED = 'expired'
+ LOCAL_SHUTDOWN = 'local shutdown'
+ REMOTE_SHUTDOWN = 'remote shutdown'
+ RECEPTION_FAILURE = 'reception failure'
+ TRANSMISSION_FAILURE = 'transmission failure'
+ LOCAL_FAILURE = 'local failure'
+ REMOTE_FAILURE = 'remote failure'
class Completion(object):
@@ -294,8 +305,8 @@ class End(object):
"""Reports the number of terminated operations broken down by outcome.
Returns:
- A dictionary from Outcome value to an integer identifying the number
- of operations that terminated with that outcome.
+ A dictionary from Outcome.Kind value to an integer identifying the number
+ of operations that terminated with that outcome kind.
"""
raise NotImplementedError()
diff --git a/src/python/grpcio/setup.py b/src/python/grpcio/setup.py
index caa71a4f7c..4735ce080b 100644
--- a/src/python/grpcio/setup.py
+++ b/src/python/grpcio/setup.py
@@ -104,7 +104,7 @@ _COMMAND_CLASS = {
setuptools.setup(
name='grpcio',
- version='0.10.0a0',
+ version='0.11.0',
ext_modules=_EXTENSION_MODULES,
packages=list(_PACKAGES),
package_dir=_PACKAGE_DIRECTORIES,
diff --git a/src/python/grpcio_test/grpc_test/_core_over_links_base_interface_test.py b/src/python/grpcio_test/grpc_test/_core_over_links_base_interface_test.py
index f0bd989ea6..cafb6b6eae 100644
--- a/src/python/grpcio_test/grpc_test/_core_over_links_base_interface_test.py
+++ b/src/python/grpcio_test/grpc_test/_core_over_links_base_interface_test.py
@@ -38,6 +38,7 @@ import unittest
from grpc._adapter import _intermediary_low
from grpc._links import invocation
from grpc._links import service
+from grpc.beta import interfaces as beta_interfaces
from grpc.framework.core import implementations
from grpc.framework.interfaces.base import utilities
from grpc_test import test_common as grpc_test_common
@@ -45,8 +46,6 @@ from grpc_test.framework.common import test_constants
from grpc_test.framework.interfaces.base import test_cases
from grpc_test.framework.interfaces.base import test_interfaces
-_CODE = _intermediary_low.Code.OK
-
class _SerializationBehaviors(
collections.namedtuple(
@@ -124,8 +123,8 @@ class _Implementation(test_interfaces.Implementation):
def service_completion(self):
return utilities.completion(
- grpc_test_common.SERVICE_TERMINAL_METADATA, _CODE,
- grpc_test_common.DETAILS)
+ grpc_test_common.SERVICE_TERMINAL_METADATA,
+ beta_interfaces.StatusCode.OK, grpc_test_common.DETAILS)
def metadata_transmitted(self, original_metadata, transmitted_metadata):
return original_metadata is None or grpc_test_common.metadata_transmitted(
diff --git a/src/python/grpcio_test/grpc_test/_crust_over_core_over_links_face_interface_test.py b/src/python/grpcio_test/grpc_test/_crust_over_core_over_links_face_interface_test.py
index 28c0619f7c..a4d4dee38c 100644
--- a/src/python/grpcio_test/grpc_test/_crust_over_core_over_links_face_interface_test.py
+++ b/src/python/grpcio_test/grpc_test/_crust_over_core_over_links_face_interface_test.py
@@ -35,6 +35,7 @@ import unittest
from grpc._adapter import _intermediary_low
from grpc._links import invocation
from grpc._links import service
+from grpc.beta import interfaces as beta_interfaces
from grpc.framework.core import implementations as core_implementations
from grpc.framework.crust import implementations as crust_implementations
from grpc.framework.foundation import logging_pool
@@ -139,7 +140,7 @@ class _Implementation(test_interfaces.Implementation):
return grpc_test_common.SERVICE_TERMINAL_METADATA
def code(self):
- return _intermediary_low.Code.OK
+ return beta_interfaces.StatusCode.OK
def details(self):
return grpc_test_common.DETAILS
diff --git a/src/python/grpcio_test/grpc_test/_links/_transmission_test.py b/src/python/grpcio_test/grpc_test/_links/_transmission_test.py
index 716323cc20..77e83d5561 100644
--- a/src/python/grpcio_test/grpc_test/_links/_transmission_test.py
+++ b/src/python/grpcio_test/grpc_test/_links/_transmission_test.py
@@ -34,6 +34,7 @@ import unittest
from grpc._adapter import _intermediary_low
from grpc._links import invocation
from grpc._links import service
+from grpc.beta import interfaces as beta_interfaces
from grpc.framework.interfaces.links import links
from grpc_test import test_common
from grpc_test._links import _proto_scenarios
@@ -93,7 +94,8 @@ class TransmissionTest(test_cases.TransmissionTest, unittest.TestCase):
return None, None
def create_service_completion(self):
- return _intermediary_low.Code.OK, 'An exuberant test "details" message!'
+ return (
+ beta_interfaces.StatusCode.OK, b'An exuberant test "details" message!')
def assertMetadataTransmitted(self, original_metadata, transmitted_metadata):
self.assertTrue(
@@ -110,7 +112,7 @@ class RoundTripTest(unittest.TestCase):
test_group = 'test package.Test Group'
test_method = 'test method'
identity_transformation = {(test_group, test_method): _IDENTITY}
- test_code = _intermediary_low.Code.OK
+ test_code = beta_interfaces.StatusCode.OK
test_message = 'a test message'
service_link = service.service_link(
@@ -150,11 +152,13 @@ class RoundTripTest(unittest.TestCase):
self.assertIs(
invocation_mate.tickets()[-1].termination,
links.Ticket.Termination.COMPLETION)
+ self.assertIs(invocation_mate.tickets()[-1].code, test_code)
+ self.assertEqual(invocation_mate.tickets()[-1].message, test_message)
def _perform_scenario_test(self, scenario):
test_operation_id = object()
test_group, test_method = scenario.group_and_method()
- test_code = _intermediary_low.Code.OK
+ test_code = beta_interfaces.StatusCode.OK
test_message = 'a scenario test message'
service_link = service.service_link(
diff --git a/src/python/grpcio_test/grpc_test/beta/_face_interface_test.py b/src/python/grpcio_test/grpc_test/beta/_face_interface_test.py
index ce4c59c0ee..e9087a7949 100644
--- a/src/python/grpcio_test/grpc_test/beta/_face_interface_test.py
+++ b/src/python/grpcio_test/grpc_test/beta/_face_interface_test.py
@@ -32,8 +32,8 @@
import collections
import unittest
-from grpc._adapter import _intermediary_low
from grpc.beta import beta
+from grpc.beta import interfaces
from grpc_test import resources
from grpc_test import test_common as grpc_test_common
from grpc_test.beta import test_utilities
@@ -116,7 +116,7 @@ class _Implementation(test_interfaces.Implementation):
return grpc_test_common.SERVICE_TERMINAL_METADATA
def code(self):
- return _intermediary_low.Code.OK
+ return interfaces.StatusCode.OK
def details(self):
return grpc_test_common.DETAILS
diff --git a/src/python/grpcio_test/grpc_test/beta/_not_found_test.py b/src/python/grpcio_test/grpc_test/beta/_not_found_test.py
new file mode 100644
index 0000000000..ecd10f2175
--- /dev/null
+++ b/src/python/grpcio_test/grpc_test/beta/_not_found_test.py
@@ -0,0 +1,75 @@
+# 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.
+
+"""Tests of RPC-method-not-found behavior."""
+
+import unittest
+
+from grpc.beta import beta
+from grpc.beta import interfaces
+from grpc.framework.interfaces.face import face
+from grpc_test.framework.common import test_constants
+
+
+class NotFoundTest(unittest.TestCase):
+
+ def setUp(self):
+ self._server = beta.server({})
+ port = self._server.add_insecure_port('[::]:0')
+ channel = beta.create_insecure_channel('localhost', port)
+ self._generic_stub = beta.generic_stub(channel)
+ self._server.start()
+
+ def tearDown(self):
+ self._server.stop(0).wait()
+ self._generic_stub = None
+
+ def test_blocking_unary_unary_not_found(self):
+ with self.assertRaises(face.LocalError) as exception_assertion_context:
+ self._generic_stub.blocking_unary_unary(
+ 'groop', 'meffod', b'abc', test_constants.LONG_TIMEOUT,
+ with_call=True)
+ self.assertIs(
+ exception_assertion_context.exception.code,
+ interfaces.StatusCode.UNIMPLEMENTED)
+
+ def test_future_stream_unary_not_found(self):
+ rpc_future = self._generic_stub.future_stream_unary(
+ 'grupe', 'mevvod', b'def', test_constants.LONG_TIMEOUT)
+ with self.assertRaises(face.LocalError) as exception_assertion_context:
+ rpc_future.result()
+ self.assertIs(
+ exception_assertion_context.exception.code,
+ interfaces.StatusCode.UNIMPLEMENTED)
+ self.assertIs(
+ rpc_future.exception().code, interfaces.StatusCode.UNIMPLEMENTED)
+
+
+if __name__ == '__main__':
+ unittest.main(verbosity=2)
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/base/_control.py b/src/python/grpcio_test/grpc_test/framework/interfaces/base/_control.py
index e4d2a7a0d7..46a01876d8 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/base/_control.py
+++ b/src/python/grpcio_test/grpc_test/framework/interfaces/base/_control.py
@@ -236,8 +236,8 @@ class Instruction(
collections.namedtuple(
'Instruction',
('kind', 'advance_args', 'advance_kwargs', 'conclude_success',
- 'conclude_message', 'conclude_invocation_outcome',
- 'conclude_service_outcome',))):
+ 'conclude_message', 'conclude_invocation_outcome_kind',
+ 'conclude_service_outcome_kind',))):
""""""
@enum.unique
@@ -532,24 +532,24 @@ class _SequenceController(Controller):
self._state.service_side_outcome = outcome
if self._todo is not None or self._remaining_elements:
self._failed('Premature service-side outcome %s!' % (outcome,))
- elif outcome is not self._sequence.outcome.service:
+ elif outcome.kind is not self._sequence.outcome_kinds.service:
self._failed(
- 'Incorrect service-side outcome: %s should have been %s' % (
- outcome, self._sequence.outcome.service))
+ 'Incorrect service-side outcome kind: %s should have been %s' % (
+ outcome.kind, self._sequence.outcome_kinds.service))
elif self._state.invocation_side_outcome is not None:
- self._passed(self._state.invocation_side_outcome, outcome)
+ self._passed(self._state.invocation_side_outcome.kind, outcome.kind)
def invocation_on_termination(self, outcome):
with self._condition:
self._state.invocation_side_outcome = outcome
if self._todo is not None or self._remaining_elements:
self._failed('Premature invocation-side outcome %s!' % (outcome,))
- elif outcome is not self._sequence.outcome.invocation:
+ elif outcome.kind is not self._sequence.outcome_kinds.invocation:
self._failed(
- 'Incorrect invocation-side outcome: %s should have been %s' % (
- outcome, self._sequence.outcome.invocation))
+ 'Incorrect invocation-side outcome kind: %s should have been %s' % (
+ outcome.kind, self._sequence.outcome_kinds.invocation))
elif self._state.service_side_outcome is not None:
- self._passed(outcome, self._state.service_side_outcome)
+ self._passed(outcome.kind, self._state.service_side_outcome.kind)
class _SequenceControllerCreator(ControllerCreator):
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/base/_sequence.py b/src/python/grpcio_test/grpc_test/framework/interfaces/base/_sequence.py
index 1d77aaebe6..f547d91681 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/base/_sequence.py
+++ b/src/python/grpcio_test/grpc_test/framework/interfaces/base/_sequence.py
@@ -103,13 +103,14 @@ class Element(collections.namedtuple('Element', ('kind', 'transmission',))):
SERVICE_FAILURE = 'service failure'
-class Outcome(collections.namedtuple('Outcome', ('invocation', 'service',))):
+class OutcomeKinds(
+ collections.namedtuple('Outcome', ('invocation', 'service',))):
"""A description of the expected outcome of an operation test.
Attributes:
- invocation: The base.Outcome value expected on the invocation side of the
- operation.
- service: The base.Outcome value expected on the service side of the
+ invocation: The base.Outcome.Kind value expected on the invocation side of
+ the operation.
+ service: The base.Outcome.Kind value expected on the service side of the
operation.
"""
@@ -117,7 +118,8 @@ class Outcome(collections.namedtuple('Outcome', ('invocation', 'service',))):
class Sequence(
collections.namedtuple(
'Sequence',
- ('name', 'maximum_duration', 'invocation', 'elements', 'outcome',))):
+ ('name', 'maximum_duration', 'invocation', 'elements',
+ 'outcome_kinds',))):
"""Describes at a high level steps to perform in a test.
Attributes:
@@ -128,7 +130,8 @@ class Sequence(
under test.
elements: A sequence of Element values describing at coarse granularity
actions to take during the operation under test.
- outcome: An Outcome value describing the expected outcome of the test.
+ outcome_kinds: An OutcomeKinds value describing the expected outcome kinds
+ of the test.
"""
_EASY = Sequence(
@@ -139,7 +142,7 @@ _EASY = Sequence(
Element(
Element.Kind.SERVICE_TRANSMISSION, Transmission(True, True, True)),
),
- Outcome(base.Outcome.COMPLETED, base.Outcome.COMPLETED))
+ OutcomeKinds(base.Outcome.Kind.COMPLETED, base.Outcome.Kind.COMPLETED))
_PEASY = Sequence(
'Peasy',
@@ -154,7 +157,7 @@ _PEASY = Sequence(
Element(
Element.Kind.SERVICE_TRANSMISSION, Transmission(False, True, True)),
),
- Outcome(base.Outcome.COMPLETED, base.Outcome.COMPLETED))
+ OutcomeKinds(base.Outcome.Kind.COMPLETED, base.Outcome.Kind.COMPLETED))
# TODO(issue 2959): Finish this test suite. This tuple of sequences should
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/base/test_cases.py b/src/python/grpcio_test/grpc_test/framework/interfaces/base/test_cases.py
index 87332cf612..5065a3f38a 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/base/test_cases.py
+++ b/src/python/grpcio_test/grpc_test/framework/interfaces/base/test_cases.py
@@ -44,7 +44,8 @@ from grpc_test.framework.interfaces.base import test_interfaces
_SYNCHRONICITY_VARIATION = (('Sync', False), ('Async', True))
-_EMPTY_OUTCOME_DICT = {outcome: 0 for outcome in base.Outcome}
+_EMPTY_OUTCOME_KIND_DICT = {
+ outcome_kind: 0 for outcome_kind in base.Outcome.Kind}
class _Serialization(test_interfaces.Serialization):
@@ -119,7 +120,7 @@ class _Operator(base.Operator):
class _Servicer(base.Servicer):
- """An base.Servicer with instrumented for testing."""
+ """A base.Servicer with instrumented for testing."""
def __init__(self, group, method, controllers, pool):
self._condition = threading.Condition()
@@ -223,11 +224,12 @@ class _OperationTest(unittest.TestCase):
self.assertTrue(
instruction.conclude_success, msg=instruction.conclude_message)
- expected_invocation_stats = dict(_EMPTY_OUTCOME_DICT)
- expected_invocation_stats[instruction.conclude_invocation_outcome] += 1
+ expected_invocation_stats = dict(_EMPTY_OUTCOME_KIND_DICT)
+ expected_invocation_stats[
+ instruction.conclude_invocation_outcome_kind] += 1
self.assertDictEqual(expected_invocation_stats, invocation_stats)
- expected_service_stats = dict(_EMPTY_OUTCOME_DICT)
- expected_service_stats[instruction.conclude_service_outcome] += 1
+ expected_service_stats = dict(_EMPTY_OUTCOME_KIND_DICT)
+ expected_service_stats[instruction.conclude_service_outcome_kind] += 1
self.assertDictEqual(expected_service_stats, service_stats)
diff --git a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_blocking_invocation_inline_service.py b/src/python/grpcio_test/grpc_test/framework/interfaces/face/_blocking_invocation_inline_service.py
index b7dd5d4d17..2d2a081955 100644
--- a/src/python/grpcio_test/grpc_test/framework/interfaces/face/_blocking_invocation_inline_service.py
+++ b/src/python/grpcio_test/grpc_test/framework/interfaces/face/_blocking_invocation_inline_service.py
@@ -82,8 +82,8 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
for test_messages in test_messages_sequence:
request = test_messages.request()
- response = self._invoker.blocking(group, method)(
- request, test_constants.LONG_TIMEOUT)
+ response, call = self._invoker.blocking(group, method)(
+ request, test_constants.LONG_TIMEOUT, with_call=True)
test_messages.verify(request, response, self)
@@ -105,8 +105,8 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
for test_messages in test_messages_sequence:
requests = test_messages.requests()
- response = self._invoker.blocking(group, method)(
- iter(requests), test_constants.LONG_TIMEOUT)
+ response, call = self._invoker.blocking(group, method)(
+ iter(requests), test_constants.LONG_TIMEOUT, with_call=True)
test_messages.verify(requests, response, self)
diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++
index 96708c0622..a352341774 100644
--- a/tools/doxygen/Doxyfile.c++
+++ b/tools/doxygen/Doxyfile.c++
@@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 0.10.1.0
+PROJECT_NUMBER = 0.11.0.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal
index 185d24720c..dfaeb43ca7 100644
--- a/tools/doxygen/Doxyfile.c++.internal
+++ b/tools/doxygen/Doxyfile.c++.internal
@@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 0.10.1.0
+PROJECT_NUMBER = 0.11.0.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core
index 4c83e22b7f..beb0128e41 100644
--- a/tools/doxygen/Doxyfile.core
+++ b/tools/doxygen/Doxyfile.core
@@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 0.10.1.0
+PROJECT_NUMBER = 0.11.0.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal
index 729f8bf2ff..fdc32c7776 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 0.10.1.0
+PROJECT_NUMBER = 0.11.0.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/tools/run_tests/build_php.sh b/tools/run_tests/build_php.sh
index 1d81779b6a..2fad09e1c4 100755
--- a/tools/run_tests/build_php.sh
+++ b/tools/run_tests/build_php.sh
@@ -46,3 +46,6 @@ cd ext/grpc
phpize
./configure --enable-grpc=$root
make
+
+# in some jenkins macos machine, somehow the PHP build script can't find libgrpc.dylib
+export DYLD_LIBRARY_PATH=$(pwd)/libs/$config
diff --git a/tools/run_tests/run_interops.py b/tools/run_tests/run_interops.py
index e1d40d32c1..17083975d8 100755
--- a/tools/run_tests/run_interops.py
+++ b/tools/run_tests/run_interops.py
@@ -8,7 +8,9 @@ argp.add_argument('-l', '--language',
args = argp.parse_args()
# build job
-build_job = jobset.JobSpec(cmdline=['tools/run_tests/run_interops_build.sh', '%s' % args.language], shortname='build')
+build_job = jobset.JobSpec(cmdline=['tools/run_tests/run_interops_build.sh', '%s' % args.language],
+ shortname='build',
+ timeout_seconds=30*60)
# test jobs, each test is a separate job to run in parallel
_TESTS = ['large_unary', 'empty_unary', 'ping_pong', 'client_streaming', 'server_streaming']
diff --git a/vsprojects/nuget_package/buildall.bat b/vsprojects/nuget_package/buildall.bat
index 80f5235fd9..71befb6920 100644
--- a/vsprojects/nuget_package/buildall.bat
+++ b/vsprojects/nuget_package/buildall.bat
@@ -39,7 +39,7 @@ endlocal
goto :eof
:build
-msbuild /P:Platform=%1 /P:Configuration=%2 /P:PlatformToolset=%3 /P:OutDir=..\nuget_package\output\%3\%1\%2\ /P:IntDir=..\nuget_package\tmp\%3\%1\%2\ ..\grpc_csharp_ext.sln || goto :eof
+msbuild /P:Platform=%1 /P:Configuration=%2 /P:PlatformToolset=%3 /P:OutDir=..\..\nuget_package\output\%3\%1\%2\ /P:IntDir=..\..\nuget_package\tmp\%3\%1\%2\ ..\grpc_csharp_ext.sln || goto :eof
goto :eof
diff --git a/vsprojects/nuget_package/grpc.native.csharp_ext.nuspec b/vsprojects/nuget_package/grpc.native.csharp_ext.nuspec
index d2ac440dab..39791a5d8e 100644
--- a/vsprojects/nuget_package/grpc.native.csharp_ext.nuspec
+++ b/vsprojects/nuget_package/grpc.native.csharp_ext.nuspec
@@ -2,21 +2,21 @@
<package>
<metadata>
<id>grpc.native.csharp_ext</id>
- <version>0.10.0</version>
+ <version>$version$</version>
<authors>Google Inc.</authors>
<owners>grpc-packages</owners>
<licenseUrl>https://github.com/grpc/grpc/blob/master/LICENSE</licenseUrl>
<projectUrl>http://github.com/grpc/grpc</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Native extension needed by gRPC C# library. This is not the package you are looking for, it is only meant to be used as a dependency.</description>
- <releaseNotes>Release of gRPC C core 0.10.0 libraries.</releaseNotes>
+ <releaseNotes>Release of gRPC C core $version$ libraries.</releaseNotes>
<copyright>Copyright 2015</copyright>
<title>gRPC C# Native Extension</title>
<summary>Native library required by gRPC C#</summary>
<tags>gRPC native</tags>
<dependencies>
<dependency id="grpc.dependencies.zlib.redist" version="1.2.8.9" />
- <dependency id="grpc.dependencies.openssl.redist" version="1.0.2.2" />
+ <dependency id="grpc.dependencies.openssl.redist" version="1.0.2.3" />
</dependencies>
</metadata>
<files>