diff options
author | Jan Tattermusch <jtattermusch@google.com> | 2015-02-20 09:34:34 -0800 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@google.com> | 2015-02-20 09:49:25 -0800 |
commit | babfd91e4ae71a5601827cebcafc73094c3d8588 (patch) | |
tree | dd282d29b0c2bd69a9d79149235f900b159ab29c /src/csharp/Grpc.Examples | |
parent | d3a792762077464f7a4b6c1f163474efd58449ce (diff) |
Rename Grpc.Api to Grpc.Examples
Diffstat (limited to 'src/csharp/Grpc.Examples')
-rw-r--r-- | src/csharp/Grpc.Examples/.gitignore | 3 | ||||
-rw-r--r-- | src/csharp/Grpc.Examples/Grpc.Examples.csproj | 69 | ||||
-rw-r--r-- | src/csharp/Grpc.Examples/Math.cs | 1531 | ||||
-rw-r--r-- | src/csharp/Grpc.Examples/MathExamples.cs | 131 | ||||
-rw-r--r-- | src/csharp/Grpc.Examples/MathGrpc.cs | 157 | ||||
-rw-r--r-- | src/csharp/Grpc.Examples/MathServiceImpl.cs | 152 | ||||
-rw-r--r-- | src/csharp/Grpc.Examples/Properties/AssemblyInfo.cs | 22 | ||||
-rw-r--r-- | src/csharp/Grpc.Examples/packages.config | 11 | ||||
-rw-r--r-- | src/csharp/Grpc.Examples/proto/math.proto | 80 |
9 files changed, 2156 insertions, 0 deletions
diff --git a/src/csharp/Grpc.Examples/.gitignore b/src/csharp/Grpc.Examples/.gitignore new file mode 100644 index 0000000000..4795a95b94 --- /dev/null +++ b/src/csharp/Grpc.Examples/.gitignore @@ -0,0 +1,3 @@ +test-results +bin +obj diff --git a/src/csharp/Grpc.Examples/Grpc.Examples.csproj b/src/csharp/Grpc.Examples/Grpc.Examples.csproj new file mode 100644 index 0000000000..1609c4e3df --- /dev/null +++ b/src/csharp/Grpc.Examples/Grpc.Examples.csproj @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>10.0.0</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{7DC1433E-3225-42C7-B7EA-546D56E27A4B}</ProjectGuid> + <OutputType>Library</OutputType> + <RootNamespace>Grpc.Examples</RootNamespace> + <AssemblyName>Grpc.Examples</AssemblyName> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug</OutputPath> + <DefineConstants>DEBUG;</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>false</ConsolePause> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>full</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release</OutputPath> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <ConsolePause>false</ConsolePause> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Reactive.Core"> + <HintPath>..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath> + </Reference> + <Reference Include="System.Reactive.Interfaces"> + <HintPath>..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll</HintPath> + </Reference> + <Reference Include="System.Data.Linq" /> + <Reference Include="System.Reactive.Linq"> + <HintPath>..\packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll</HintPath> + </Reference> + <Reference Include="System.Reactive.PlatformServices"> + <HintPath>..\packages\Rx-PlatformServices.2.2.5\lib\net45\System.Reactive.PlatformServices.dll</HintPath> + </Reference> + <Reference Include="Google.ProtocolBuffers"> + <HintPath>..\packages\Google.ProtocolBuffers.2.4.1.521\lib\net40\Google.ProtocolBuffers.dll</HintPath> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Math.cs" /> + <Compile Include="MathGrpc.cs" /> + <Compile Include="MathServiceImpl.cs" /> + <Compile Include="MathExamples.cs" /> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <ItemGroup> + <ProjectReference Include="..\Grpc.Core\Grpc.Core.csproj"> + <Project>{CCC4440E-49F7-4790-B0AF-FEABB0837AE7}</Project> + <Name>Grpc.Core</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + <None Include="proto\math.proto" /> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/src/csharp/Grpc.Examples/Math.cs b/src/csharp/Grpc.Examples/Math.cs new file mode 100644 index 0000000000..75b1e9dbc2 --- /dev/null +++ b/src/csharp/Grpc.Examples/Math.cs @@ -0,0 +1,1531 @@ +// Generated by ProtoGen, Version=2.4.1.521, Culture=neutral, PublicKeyToken=17b3b1f090c3ea48. DO NOT EDIT! +#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 math { + + namespace Proto { + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public static partial class Math { + + #region Extension registration + public static void RegisterAllExtensions(pb::ExtensionRegistry registry) { + } + #endregion + #region Static variables + internal static pbd::MessageDescriptor internal__static_math_DivArgs__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable<global::math.DivArgs, global::math.DivArgs.Builder> internal__static_math_DivArgs__FieldAccessorTable; + internal static pbd::MessageDescriptor internal__static_math_DivReply__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable<global::math.DivReply, global::math.DivReply.Builder> internal__static_math_DivReply__FieldAccessorTable; + internal static pbd::MessageDescriptor internal__static_math_FibArgs__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable<global::math.FibArgs, global::math.FibArgs.Builder> internal__static_math_FibArgs__FieldAccessorTable; + internal static pbd::MessageDescriptor internal__static_math_Num__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable<global::math.Num, global::math.Num.Builder> internal__static_math_Num__FieldAccessorTable; + internal static pbd::MessageDescriptor internal__static_math_FibReply__Descriptor; + internal static pb::FieldAccess.FieldAccessorTable<global::math.FibReply, global::math.FibReply.Builder> internal__static_math_FibReply__FieldAccessorTable; + #endregion + #region Descriptor + public static pbd::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbd::FileDescriptor descriptor; + + static Math() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgptYXRoLnByb3RvEgRtYXRoIiwKB0RpdkFyZ3MSEAoIZGl2aWRlbmQYASAB", + "KAMSDwoHZGl2aXNvchgCIAEoAyIvCghEaXZSZXBseRIQCghxdW90aWVudBgB", + "IAEoAxIRCglyZW1haW5kZXIYAiABKAMiGAoHRmliQXJncxINCgVsaW1pdBgB", + "IAEoAyISCgNOdW0SCwoDbnVtGAEgASgDIhkKCEZpYlJlcGx5Eg0KBWNvdW50", + "GAEgASgDMqQBCgRNYXRoEiYKA0RpdhINLm1hdGguRGl2QXJncxoOLm1hdGgu", + "RGl2UmVwbHkiABIuCgdEaXZNYW55Eg0ubWF0aC5EaXZBcmdzGg4ubWF0aC5E", + "aXZSZXBseSIAKAEwARIjCgNGaWISDS5tYXRoLkZpYkFyZ3MaCS5tYXRoLk51", + "bSIAMAESHwoDU3VtEgkubWF0aC5OdW0aCS5tYXRoLk51bSIAKAE=")); + pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate(pbd::FileDescriptor root) { + descriptor = root; + internal__static_math_DivArgs__Descriptor = Descriptor.MessageTypes[0]; + internal__static_math_DivArgs__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable<global::math.DivArgs, global::math.DivArgs.Builder>(internal__static_math_DivArgs__Descriptor, + new string[] { "Dividend", "Divisor", }); + internal__static_math_DivReply__Descriptor = Descriptor.MessageTypes[1]; + internal__static_math_DivReply__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable<global::math.DivReply, global::math.DivReply.Builder>(internal__static_math_DivReply__Descriptor, + new string[] { "Quotient", "Remainder", }); + internal__static_math_FibArgs__Descriptor = Descriptor.MessageTypes[2]; + internal__static_math_FibArgs__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable<global::math.FibArgs, global::math.FibArgs.Builder>(internal__static_math_FibArgs__Descriptor, + new string[] { "Limit", }); + internal__static_math_Num__Descriptor = Descriptor.MessageTypes[3]; + internal__static_math_Num__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable<global::math.Num, global::math.Num.Builder>(internal__static_math_Num__Descriptor, + new string[] { "Num_", }); + internal__static_math_FibReply__Descriptor = Descriptor.MessageTypes[4]; + internal__static_math_FibReply__FieldAccessorTable = + new pb::FieldAccess.FieldAccessorTable<global::math.FibReply, global::math.FibReply.Builder>(internal__static_math_FibReply__Descriptor, + new string[] { "Count", }); + 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 DivArgs : pb::GeneratedMessage<DivArgs, DivArgs.Builder> { + private DivArgs() { } + private static readonly DivArgs defaultInstance = new DivArgs().MakeReadOnly(); + private static readonly string[] _divArgsFieldNames = new string[] { "dividend", "divisor" }; + private static readonly uint[] _divArgsFieldTags = new uint[] { 8, 16 }; + public static DivArgs DefaultInstance { + get { return defaultInstance; } + } + + public override DivArgs DefaultInstanceForType { + get { return DefaultInstance; } + } + + protected override DivArgs ThisMessage { + get { return this; } + } + + public static pbd::MessageDescriptor Descriptor { + get { return global::math.Proto.Math.internal__static_math_DivArgs__Descriptor; } + } + + protected override pb::FieldAccess.FieldAccessorTable<DivArgs, DivArgs.Builder> InternalFieldAccessors { + get { return global::math.Proto.Math.internal__static_math_DivArgs__FieldAccessorTable; } + } + + public const int DividendFieldNumber = 1; + private bool hasDividend; + private long dividend_; + public bool HasDividend { + get { return hasDividend; } + } + public long Dividend { + get { return dividend_; } + } + + public const int DivisorFieldNumber = 2; + private bool hasDivisor; + private long divisor_; + public bool HasDivisor { + get { return hasDivisor; } + } + public long Divisor { + get { return divisor_; } + } + + public override bool IsInitialized { + get { + return true; + } + } + + public override void WriteTo(pb::ICodedOutputStream output) { + int size = SerializedSize; + string[] field_names = _divArgsFieldNames; + if (hasDividend) { + output.WriteInt64(1, field_names[0], Dividend); + } + if (hasDivisor) { + output.WriteInt64(2, field_names[1], Divisor); + } + UnknownFields.WriteTo(output); + } + + private int memoizedSerializedSize = -1; + public override int SerializedSize { + get { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasDividend) { + size += pb::CodedOutputStream.ComputeInt64Size(1, Dividend); + } + if (hasDivisor) { + size += pb::CodedOutputStream.ComputeInt64Size(2, Divisor); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } + } + + public static DivArgs ParseFrom(pb::ByteString data) { + return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); + } + public static DivArgs ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); + } + public static DivArgs ParseFrom(byte[] data) { + return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); + } + public static DivArgs ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); + } + public static DivArgs ParseFrom(global::System.IO.Stream input) { + return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); + } + public static DivArgs ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); + } + public static DivArgs ParseDelimitedFrom(global::System.IO.Stream input) { + return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); + } + public static DivArgs ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { + return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); + } + public static DivArgs ParseFrom(pb::ICodedInputStream input) { + return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); + } + public static DivArgs ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); + } + private DivArgs 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(DivArgs prototype) { + return new Builder(prototype); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Builder : pb::GeneratedBuilder<DivArgs, Builder> { + protected override Builder ThisBuilder { + get { return this; } + } + public Builder() { + result = DefaultInstance; + resultIsReadOnly = true; + } + internal Builder(DivArgs cloneFrom) { + result = cloneFrom; + resultIsReadOnly = true; + } + + private bool resultIsReadOnly; + private DivArgs result; + + private DivArgs PrepareBuilder() { + if (resultIsReadOnly) { + DivArgs original = result; + result = new DivArgs(); + resultIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } + + protected override DivArgs 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::math.DivArgs.Descriptor; } + } + + public override DivArgs DefaultInstanceForType { + get { return global::math.DivArgs.DefaultInstance; } + } + + public override DivArgs BuildPartial() { + if (resultIsReadOnly) { + return result; + } + resultIsReadOnly = true; + return result.MakeReadOnly(); + } + + public override Builder MergeFrom(pb::IMessage other) { + if (other is DivArgs) { + return MergeFrom((DivArgs) other); + } else { + base.MergeFrom(other); + return this; + } + } + + public override Builder MergeFrom(DivArgs other) { + if (other == global::math.DivArgs.DefaultInstance) return this; + PrepareBuilder(); + if (other.HasDividend) { + Dividend = other.Dividend; + } + if (other.HasDivisor) { + Divisor = other.Divisor; + } + 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(_divArgsFieldNames, field_name, global::System.StringComparer.Ordinal); + if(field_ordinal >= 0) + tag = _divArgsFieldTags[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 8: { + result.hasDividend = input.ReadInt64(ref result.dividend_); + break; + } + case 16: { + result.hasDivisor = input.ReadInt64(ref result.divisor_); + break; + } + } + } + + if (unknownFields != null) { + this.UnknownFields = unknownFields.Build(); + } + return this; + } + + + public bool HasDividend { + get { return result.hasDividend; } + } + public long Dividend { + get { return result.Dividend; } + set { SetDividend(value); } + } + public Builder SetDividend(long value) { + PrepareBuilder(); + result.hasDividend = true; + result.dividend_ = value; + return this; + } + public Builder ClearDividend() { + PrepareBuilder(); + result.hasDividend = false; + result.dividend_ = 0L; + return this; + } + + public bool HasDivisor { + get { return result.hasDivisor; } + } + public long Divisor { + get { return result.Divisor; } + set { SetDivisor(value); } + } + public Builder SetDivisor(long value) { + PrepareBuilder(); + result.hasDivisor = true; + result.divisor_ = value; + return this; + } + public Builder ClearDivisor() { + PrepareBuilder(); + result.hasDivisor = false; + result.divisor_ = 0L; + return this; + } + } + static DivArgs() { + object.ReferenceEquals(global::math.Proto.Math.Descriptor, null); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class DivReply : pb::GeneratedMessage<DivReply, DivReply.Builder> { + private DivReply() { } + private static readonly DivReply defaultInstance = new DivReply().MakeReadOnly(); + private static readonly string[] _divReplyFieldNames = new string[] { "quotient", "remainder" }; + private static readonly uint[] _divReplyFieldTags = new uint[] { 8, 16 }; + public static DivReply DefaultInstance { + get { return defaultInstance; } + } + + public override DivReply DefaultInstanceForType { + get { return DefaultInstance; } + } + + protected override DivReply ThisMessage { + get { return this; } + } + + public static pbd::MessageDescriptor Descriptor { + get { return global::math.Proto.Math.internal__static_math_DivReply__Descriptor; } + } + + protected override pb::FieldAccess.FieldAccessorTable<DivReply, DivReply.Builder> InternalFieldAccessors { + get { return global::math.Proto.Math.internal__static_math_DivReply__FieldAccessorTable; } + } + + public const int QuotientFieldNumber = 1; + private bool hasQuotient; + private long quotient_; + public bool HasQuotient { + get { return hasQuotient; } + } + public long Quotient { + get { return quotient_; } + } + + public const int RemainderFieldNumber = 2; + private bool hasRemainder; + private long remainder_; + public bool HasRemainder { + get { return hasRemainder; } + } + public long Remainder { + get { return remainder_; } + } + + public override bool IsInitialized { + get { + return true; + } + } + + public override void WriteTo(pb::ICodedOutputStream output) { + int size = SerializedSize; + string[] field_names = _divReplyFieldNames; + if (hasQuotient) { + output.WriteInt64(1, field_names[0], Quotient); + } + if (hasRemainder) { + output.WriteInt64(2, field_names[1], Remainder); + } + UnknownFields.WriteTo(output); + } + + private int memoizedSerializedSize = -1; + public override int SerializedSize { + get { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasQuotient) { + size += pb::CodedOutputStream.ComputeInt64Size(1, Quotient); + } + if (hasRemainder) { + size += pb::CodedOutputStream.ComputeInt64Size(2, Remainder); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } + } + + public static DivReply ParseFrom(pb::ByteString data) { + return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); + } + public static DivReply ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); + } + public static DivReply ParseFrom(byte[] data) { + return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); + } + public static DivReply ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); + } + public static DivReply ParseFrom(global::System.IO.Stream input) { + return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); + } + public static DivReply ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); + } + public static DivReply ParseDelimitedFrom(global::System.IO.Stream input) { + return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); + } + public static DivReply ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { + return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); + } + public static DivReply ParseFrom(pb::ICodedInputStream input) { + return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); + } + public static DivReply ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); + } + private DivReply 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(DivReply prototype) { + return new Builder(prototype); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Builder : pb::GeneratedBuilder<DivReply, Builder> { + protected override Builder ThisBuilder { + get { return this; } + } + public Builder() { + result = DefaultInstance; + resultIsReadOnly = true; + } + internal Builder(DivReply cloneFrom) { + result = cloneFrom; + resultIsReadOnly = true; + } + + private bool resultIsReadOnly; + private DivReply result; + + private DivReply PrepareBuilder() { + if (resultIsReadOnly) { + DivReply original = result; + result = new DivReply(); + resultIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } + + protected override DivReply 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::math.DivReply.Descriptor; } + } + + public override DivReply DefaultInstanceForType { + get { return global::math.DivReply.DefaultInstance; } + } + + public override DivReply BuildPartial() { + if (resultIsReadOnly) { + return result; + } + resultIsReadOnly = true; + return result.MakeReadOnly(); + } + + public override Builder MergeFrom(pb::IMessage other) { + if (other is DivReply) { + return MergeFrom((DivReply) other); + } else { + base.MergeFrom(other); + return this; + } + } + + public override Builder MergeFrom(DivReply other) { + if (other == global::math.DivReply.DefaultInstance) return this; + PrepareBuilder(); + if (other.HasQuotient) { + Quotient = other.Quotient; + } + if (other.HasRemainder) { + Remainder = other.Remainder; + } + 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(_divReplyFieldNames, field_name, global::System.StringComparer.Ordinal); + if(field_ordinal >= 0) + tag = _divReplyFieldTags[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 8: { + result.hasQuotient = input.ReadInt64(ref result.quotient_); + break; + } + case 16: { + result.hasRemainder = input.ReadInt64(ref result.remainder_); + break; + } + } + } + + if (unknownFields != null) { + this.UnknownFields = unknownFields.Build(); + } + return this; + } + + + public bool HasQuotient { + get { return result.hasQuotient; } + } + public long Quotient { + get { return result.Quotient; } + set { SetQuotient(value); } + } + public Builder SetQuotient(long value) { + PrepareBuilder(); + result.hasQuotient = true; + result.quotient_ = value; + return this; + } + public Builder ClearQuotient() { + PrepareBuilder(); + result.hasQuotient = false; + result.quotient_ = 0L; + return this; + } + + public bool HasRemainder { + get { return result.hasRemainder; } + } + public long Remainder { + get { return result.Remainder; } + set { SetRemainder(value); } + } + public Builder SetRemainder(long value) { + PrepareBuilder(); + result.hasRemainder = true; + result.remainder_ = value; + return this; + } + public Builder ClearRemainder() { + PrepareBuilder(); + result.hasRemainder = false; + result.remainder_ = 0L; + return this; + } + } + static DivReply() { + object.ReferenceEquals(global::math.Proto.Math.Descriptor, null); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class FibArgs : pb::GeneratedMessage<FibArgs, FibArgs.Builder> { + private FibArgs() { } + private static readonly FibArgs defaultInstance = new FibArgs().MakeReadOnly(); + private static readonly string[] _fibArgsFieldNames = new string[] { "limit" }; + private static readonly uint[] _fibArgsFieldTags = new uint[] { 8 }; + public static FibArgs DefaultInstance { + get { return defaultInstance; } + } + + public override FibArgs DefaultInstanceForType { + get { return DefaultInstance; } + } + + protected override FibArgs ThisMessage { + get { return this; } + } + + public static pbd::MessageDescriptor Descriptor { + get { return global::math.Proto.Math.internal__static_math_FibArgs__Descriptor; } + } + + protected override pb::FieldAccess.FieldAccessorTable<FibArgs, FibArgs.Builder> InternalFieldAccessors { + get { return global::math.Proto.Math.internal__static_math_FibArgs__FieldAccessorTable; } + } + + public const int LimitFieldNumber = 1; + private bool hasLimit; + private long limit_; + public bool HasLimit { + get { return hasLimit; } + } + public long Limit { + get { return limit_; } + } + + public override bool IsInitialized { + get { + return true; + } + } + + public override void WriteTo(pb::ICodedOutputStream output) { + int size = SerializedSize; + string[] field_names = _fibArgsFieldNames; + if (hasLimit) { + output.WriteInt64(1, field_names[0], Limit); + } + UnknownFields.WriteTo(output); + } + + private int memoizedSerializedSize = -1; + public override int SerializedSize { + get { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasLimit) { + size += pb::CodedOutputStream.ComputeInt64Size(1, Limit); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } + } + + public static FibArgs ParseFrom(pb::ByteString data) { + return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); + } + public static FibArgs ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); + } + public static FibArgs ParseFrom(byte[] data) { + return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); + } + public static FibArgs ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); + } + public static FibArgs ParseFrom(global::System.IO.Stream input) { + return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); + } + public static FibArgs ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); + } + public static FibArgs ParseDelimitedFrom(global::System.IO.Stream input) { + return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); + } + public static FibArgs ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { + return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); + } + public static FibArgs ParseFrom(pb::ICodedInputStream input) { + return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); + } + public static FibArgs ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); + } + private FibArgs 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(FibArgs prototype) { + return new Builder(prototype); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Builder : pb::GeneratedBuilder<FibArgs, Builder> { + protected override Builder ThisBuilder { + get { return this; } + } + public Builder() { + result = DefaultInstance; + resultIsReadOnly = true; + } + internal Builder(FibArgs cloneFrom) { + result = cloneFrom; + resultIsReadOnly = true; + } + + private bool resultIsReadOnly; + private FibArgs result; + + private FibArgs PrepareBuilder() { + if (resultIsReadOnly) { + FibArgs original = result; + result = new FibArgs(); + resultIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } + + protected override FibArgs 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::math.FibArgs.Descriptor; } + } + + public override FibArgs DefaultInstanceForType { + get { return global::math.FibArgs.DefaultInstance; } + } + + public override FibArgs BuildPartial() { + if (resultIsReadOnly) { + return result; + } + resultIsReadOnly = true; + return result.MakeReadOnly(); + } + + public override Builder MergeFrom(pb::IMessage other) { + if (other is FibArgs) { + return MergeFrom((FibArgs) other); + } else { + base.MergeFrom(other); + return this; + } + } + + public override Builder MergeFrom(FibArgs other) { + if (other == global::math.FibArgs.DefaultInstance) return this; + PrepareBuilder(); + if (other.HasLimit) { + Limit = other.Limit; + } + 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(_fibArgsFieldNames, field_name, global::System.StringComparer.Ordinal); + if(field_ordinal >= 0) + tag = _fibArgsFieldTags[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 8: { + result.hasLimit = input.ReadInt64(ref result.limit_); + break; + } + } + } + + if (unknownFields != null) { + this.UnknownFields = unknownFields.Build(); + } + return this; + } + + + public bool HasLimit { + get { return result.hasLimit; } + } + public long Limit { + get { return result.Limit; } + set { SetLimit(value); } + } + public Builder SetLimit(long value) { + PrepareBuilder(); + result.hasLimit = true; + result.limit_ = value; + return this; + } + public Builder ClearLimit() { + PrepareBuilder(); + result.hasLimit = false; + result.limit_ = 0L; + return this; + } + } + static FibArgs() { + object.ReferenceEquals(global::math.Proto.Math.Descriptor, null); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Num : pb::GeneratedMessage<Num, Num.Builder> { + private Num() { } + private static readonly Num defaultInstance = new Num().MakeReadOnly(); + private static readonly string[] _numFieldNames = new string[] { "num" }; + private static readonly uint[] _numFieldTags = new uint[] { 8 }; + public static Num DefaultInstance { + get { return defaultInstance; } + } + + public override Num DefaultInstanceForType { + get { return DefaultInstance; } + } + + protected override Num ThisMessage { + get { return this; } + } + + public static pbd::MessageDescriptor Descriptor { + get { return global::math.Proto.Math.internal__static_math_Num__Descriptor; } + } + + protected override pb::FieldAccess.FieldAccessorTable<Num, Num.Builder> InternalFieldAccessors { + get { return global::math.Proto.Math.internal__static_math_Num__FieldAccessorTable; } + } + + public const int Num_FieldNumber = 1; + private bool hasNum_; + private long num_; + public bool HasNum_ { + get { return hasNum_; } + } + public long Num_ { + get { return num_; } + } + + public override bool IsInitialized { + get { + return true; + } + } + + public override void WriteTo(pb::ICodedOutputStream output) { + int size = SerializedSize; + string[] field_names = _numFieldNames; + if (hasNum_) { + output.WriteInt64(1, field_names[0], Num_); + } + UnknownFields.WriteTo(output); + } + + private int memoizedSerializedSize = -1; + public override int SerializedSize { + get { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasNum_) { + size += pb::CodedOutputStream.ComputeInt64Size(1, Num_); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } + } + + public static Num ParseFrom(pb::ByteString data) { + return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); + } + public static Num ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); + } + public static Num ParseFrom(byte[] data) { + return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); + } + public static Num ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); + } + public static Num ParseFrom(global::System.IO.Stream input) { + return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); + } + public static Num ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); + } + public static Num ParseDelimitedFrom(global::System.IO.Stream input) { + return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); + } + public static Num ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { + return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); + } + public static Num ParseFrom(pb::ICodedInputStream input) { + return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); + } + public static Num ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); + } + private Num 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(Num prototype) { + return new Builder(prototype); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Builder : pb::GeneratedBuilder<Num, Builder> { + protected override Builder ThisBuilder { + get { return this; } + } + public Builder() { + result = DefaultInstance; + resultIsReadOnly = true; + } + internal Builder(Num cloneFrom) { + result = cloneFrom; + resultIsReadOnly = true; + } + + private bool resultIsReadOnly; + private Num result; + + private Num PrepareBuilder() { + if (resultIsReadOnly) { + Num original = result; + result = new Num(); + resultIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } + + protected override Num 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::math.Num.Descriptor; } + } + + public override Num DefaultInstanceForType { + get { return global::math.Num.DefaultInstance; } + } + + public override Num BuildPartial() { + if (resultIsReadOnly) { + return result; + } + resultIsReadOnly = true; + return result.MakeReadOnly(); + } + + public override Builder MergeFrom(pb::IMessage other) { + if (other is Num) { + return MergeFrom((Num) other); + } else { + base.MergeFrom(other); + return this; + } + } + + public override Builder MergeFrom(Num other) { + if (other == global::math.Num.DefaultInstance) return this; + PrepareBuilder(); + if (other.HasNum_) { + Num_ = other.Num_; + } + 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(_numFieldNames, field_name, global::System.StringComparer.Ordinal); + if(field_ordinal >= 0) + tag = _numFieldTags[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 8: { + result.hasNum_ = input.ReadInt64(ref result.num_); + break; + } + } + } + + if (unknownFields != null) { + this.UnknownFields = unknownFields.Build(); + } + return this; + } + + + public bool HasNum_ { + get { return result.hasNum_; } + } + public long Num_ { + get { return result.Num_; } + set { SetNum_(value); } + } + public Builder SetNum_(long value) { + PrepareBuilder(); + result.hasNum_ = true; + result.num_ = value; + return this; + } + public Builder ClearNum_() { + PrepareBuilder(); + result.hasNum_ = false; + result.num_ = 0L; + return this; + } + } + static Num() { + object.ReferenceEquals(global::math.Proto.Math.Descriptor, null); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class FibReply : pb::GeneratedMessage<FibReply, FibReply.Builder> { + private FibReply() { } + private static readonly FibReply defaultInstance = new FibReply().MakeReadOnly(); + private static readonly string[] _fibReplyFieldNames = new string[] { "count" }; + private static readonly uint[] _fibReplyFieldTags = new uint[] { 8 }; + public static FibReply DefaultInstance { + get { return defaultInstance; } + } + + public override FibReply DefaultInstanceForType { + get { return DefaultInstance; } + } + + protected override FibReply ThisMessage { + get { return this; } + } + + public static pbd::MessageDescriptor Descriptor { + get { return global::math.Proto.Math.internal__static_math_FibReply__Descriptor; } + } + + protected override pb::FieldAccess.FieldAccessorTable<FibReply, FibReply.Builder> InternalFieldAccessors { + get { return global::math.Proto.Math.internal__static_math_FibReply__FieldAccessorTable; } + } + + public const int CountFieldNumber = 1; + private bool hasCount; + private long count_; + public bool HasCount { + get { return hasCount; } + } + public long Count { + get { return count_; } + } + + public override bool IsInitialized { + get { + return true; + } + } + + public override void WriteTo(pb::ICodedOutputStream output) { + int size = SerializedSize; + string[] field_names = _fibReplyFieldNames; + if (hasCount) { + output.WriteInt64(1, field_names[0], Count); + } + UnknownFields.WriteTo(output); + } + + private int memoizedSerializedSize = -1; + public override int SerializedSize { + get { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasCount) { + size += pb::CodedOutputStream.ComputeInt64Size(1, Count); + } + size += UnknownFields.SerializedSize; + memoizedSerializedSize = size; + return size; + } + } + + public static FibReply ParseFrom(pb::ByteString data) { + return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); + } + public static FibReply ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); + } + public static FibReply ParseFrom(byte[] data) { + return ((Builder) CreateBuilder().MergeFrom(data)).BuildParsed(); + } + public static FibReply ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed(); + } + public static FibReply ParseFrom(global::System.IO.Stream input) { + return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); + } + public static FibReply ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); + } + public static FibReply ParseDelimitedFrom(global::System.IO.Stream input) { + return CreateBuilder().MergeDelimitedFrom(input).BuildParsed(); + } + public static FibReply ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry) { + return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed(); + } + public static FibReply ParseFrom(pb::ICodedInputStream input) { + return ((Builder) CreateBuilder().MergeFrom(input)).BuildParsed(); + } + public static FibReply ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry) { + return ((Builder) CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed(); + } + private FibReply 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(FibReply prototype) { + return new Builder(prototype); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public sealed partial class Builder : pb::GeneratedBuilder<FibReply, Builder> { + protected override Builder ThisBuilder { + get { return this; } + } + public Builder() { + result = DefaultInstance; + resultIsReadOnly = true; + } + internal Builder(FibReply cloneFrom) { + result = cloneFrom; + resultIsReadOnly = true; + } + + private bool resultIsReadOnly; + private FibReply result; + + private FibReply PrepareBuilder() { + if (resultIsReadOnly) { + FibReply original = result; + result = new FibReply(); + resultIsReadOnly = false; + MergeFrom(original); + } + return result; + } + + public override bool IsInitialized { + get { return result.IsInitialized; } + } + + protected override FibReply 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::math.FibReply.Descriptor; } + } + + public override FibReply DefaultInstanceForType { + get { return global::math.FibReply.DefaultInstance; } + } + + public override FibReply BuildPartial() { + if (resultIsReadOnly) { + return result; + } + resultIsReadOnly = true; + return result.MakeReadOnly(); + } + + public override Builder MergeFrom(pb::IMessage other) { + if (other is FibReply) { + return MergeFrom((FibReply) other); + } else { + base.MergeFrom(other); + return this; + } + } + + public override Builder MergeFrom(FibReply other) { + if (other == global::math.FibReply.DefaultInstance) return this; + PrepareBuilder(); + if (other.HasCount) { + Count = other.Count; + } + 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(_fibReplyFieldNames, field_name, global::System.StringComparer.Ordinal); + if(field_ordinal >= 0) + tag = _fibReplyFieldTags[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 8: { + result.hasCount = input.ReadInt64(ref result.count_); + break; + } + } + } + + if (unknownFields != null) { + this.UnknownFields = unknownFields.Build(); + } + return this; + } + + + public bool HasCount { + get { return result.hasCount; } + } + public long Count { + get { return result.Count; } + set { SetCount(value); } + } + public Builder SetCount(long value) { + PrepareBuilder(); + result.hasCount = true; + result.count_ = value; + return this; + } + public Builder ClearCount() { + PrepareBuilder(); + result.hasCount = false; + result.count_ = 0L; + return this; + } + } + static FibReply() { + object.ReferenceEquals(global::math.Proto.Math.Descriptor, null); + } + } + + #endregion + + #region Services + /* + * Service generation is now disabled by default, use the following option to enable: + * option (google.protobuf.csharp_file_options).service_generator_type = GENERIC; + */ + #endregion + +} + +#endregion Designer generated code diff --git a/src/csharp/Grpc.Examples/MathExamples.cs b/src/csharp/Grpc.Examples/MathExamples.cs new file mode 100644 index 0000000000..97c91b1b1b --- /dev/null +++ b/src/csharp/Grpc.Examples/MathExamples.cs @@ -0,0 +1,131 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; +using System.Collections.Generic; +using System.Reactive.Linq; +using System.Threading.Tasks; +using Grpc.Core.Utils; + +namespace math +{ + public static class MathExamples + { + public static void DivExample(MathGrpc.IMathServiceClient stub) + { + DivReply result = stub.Div(new DivArgs.Builder { Dividend = 10, Divisor = 3 }.Build()); + Console.WriteLine("Div Result: " + result); + } + + public static void DivAsyncExample(MathGrpc.IMathServiceClient stub) + { + Task<DivReply> call = stub.DivAsync(new DivArgs.Builder { Dividend = 4, Divisor = 5 }.Build()); + DivReply result = call.Result; + Console.WriteLine(result); + } + + public static void DivAsyncWithCancellationExample(MathGrpc.IMathServiceClient stub) + { + Task<DivReply> call = stub.DivAsync(new DivArgs.Builder { Dividend = 4, Divisor = 5 }.Build()); + DivReply result = call.Result; + Console.WriteLine(result); + } + + public static void FibExample(MathGrpc.IMathServiceClient stub) + { + var recorder = new RecordingObserver<Num>(); + stub.Fib(new FibArgs.Builder { Limit = 5 }.Build(), recorder); + + List<Num> numbers = recorder.ToList().Result; + Console.WriteLine("Fib Result: " + string.Join("|", recorder.ToList().Result)); + } + + public static void SumExample(MathGrpc.IMathServiceClient stub) + { + List<Num> numbers = new List<Num>{new Num.Builder { Num_ = 1 }.Build(), + new Num.Builder { Num_ = 2 }.Build(), + new Num.Builder { Num_ = 3 }.Build()}; + + var res = stub.Sum(); + foreach (var num in numbers) { + res.Inputs.OnNext(num); + } + res.Inputs.OnCompleted(); + + Console.WriteLine("Sum Result: " + res.Task.Result); + } + + public static void DivManyExample(MathGrpc.IMathServiceClient stub) + { + List<DivArgs> divArgsList = new List<DivArgs>{ + new DivArgs.Builder { Dividend = 10, Divisor = 3 }.Build(), + new DivArgs.Builder { Dividend = 100, Divisor = 21 }.Build(), + new DivArgs.Builder { Dividend = 7, Divisor = 2 }.Build() + }; + + var recorder = new RecordingObserver<DivReply>(); + + var inputs = stub.DivMany(recorder); + foreach (var input in divArgsList) + { + inputs.OnNext(input); + } + inputs.OnCompleted(); + + Console.WriteLine("DivMany Result: " + string.Join("|", recorder.ToList().Result)); + } + + public static void DependendRequestsExample(MathGrpc.IMathServiceClient stub) + { + var numberList = new List<Num> + { new Num.Builder{ Num_ = 1 }.Build(), + new Num.Builder{ Num_ = 2 }.Build(), new Num.Builder{ Num_ = 3 }.Build() + }; + + numberList.ToObservable(); + + //IObserver<Num> numbers; + //Task<Num> call = stub.Sum(out numbers); + //foreach (var num in numberList) + //{ + // numbers.OnNext(num); + //} + //numbers.OnCompleted(); + + //Num sum = call.Result; + + //DivReply result = stub.Div(new DivArgs.Builder { Dividend = sum.Num_, Divisor = numberList.Count }.Build()); + } + } +} + diff --git a/src/csharp/Grpc.Examples/MathGrpc.cs b/src/csharp/Grpc.Examples/MathGrpc.cs new file mode 100644 index 0000000000..f938a24543 --- /dev/null +++ b/src/csharp/Grpc.Examples/MathGrpc.cs @@ -0,0 +1,157 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; +using System.Collections.Generic; +using System.Reactive.Linq; +using System.Threading; +using System.Threading.Tasks; +using Grpc.Core; + +namespace math +{ + /// <summary> + /// Math service definitions (this is handwritten version of code that will normally be generated). + /// </summary> + public class MathGrpc + { + readonly static Marshaller<DivArgs> divArgsMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), DivArgs.ParseFrom); + readonly static Marshaller<DivReply> divReplyMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), DivReply.ParseFrom); + readonly static Marshaller<Num> numMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), Num.ParseFrom); + readonly static Marshaller<FibArgs> fibArgsMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), FibArgs.ParseFrom); + + readonly static Method<DivArgs, DivReply> divMethod = new Method<DivArgs, DivReply>( + MethodType.Unary, + "/math.Math/Div", + divArgsMarshaller, + divReplyMarshaller + ); + readonly static Method<FibArgs, Num> fibMethod = new Method<FibArgs, Num>( + MethodType.ServerStreaming, + "/math.Math/Fib", + fibArgsMarshaller, + numMarshaller + ); + readonly static Method<Num, Num> sumMethod = new Method<Num, Num>( + MethodType.ClientStreaming, + "/math.Math/Sum", + numMarshaller, + numMarshaller + ); + readonly static Method<DivArgs, DivReply> divManyMethod = new Method<DivArgs, DivReply>( + MethodType.DuplexStreaming, + "/math.Math/DivMany", + divArgsMarshaller, + divReplyMarshaller + ); + + public interface IMathServiceClient + { + DivReply Div(DivArgs request, CancellationToken token = default(CancellationToken)); + + Task<DivReply> DivAsync(DivArgs request, CancellationToken token = default(CancellationToken)); + + void Fib(FibArgs request, IObserver<Num> responseObserver, CancellationToken token = default(CancellationToken)); + + ClientStreamingAsyncResult<Num, Num> Sum(CancellationToken token = default(CancellationToken)); + + IObserver<DivArgs> DivMany(IObserver<DivReply> responseObserver, CancellationToken token = default(CancellationToken)); + } + + public class MathServiceClientStub : IMathServiceClient + { + readonly Channel channel; + + public MathServiceClientStub(Channel channel) + { + this.channel = channel; + } + + public DivReply Div(DivArgs request, CancellationToken token = default(CancellationToken)) + { + var call = new Grpc.Core.Call<DivArgs, DivReply>(divMethod, channel); + return Calls.BlockingUnaryCall(call, request, token); + } + + public Task<DivReply> DivAsync(DivArgs request, CancellationToken token = default(CancellationToken)) + { + var call = new Grpc.Core.Call<DivArgs, DivReply>(divMethod, channel); + return Calls.AsyncUnaryCall(call, request, token); + } + + public void Fib(FibArgs request, IObserver<Num> responseObserver, CancellationToken token = default(CancellationToken)) + { + var call = new Grpc.Core.Call<FibArgs, Num>(fibMethod, channel); + Calls.AsyncServerStreamingCall(call, request, responseObserver, token); + } + + public ClientStreamingAsyncResult<Num, Num> Sum(CancellationToken token = default(CancellationToken)) + { + var call = new Grpc.Core.Call<Num, Num>(sumMethod, channel); + return Calls.AsyncClientStreamingCall(call, token); + } + + public IObserver<DivArgs> DivMany(IObserver<DivReply> responseObserver, CancellationToken token = default(CancellationToken)) + { + var call = new Grpc.Core.Call<DivArgs, DivReply>(divManyMethod, channel); + return Calls.DuplexStreamingCall(call, responseObserver, token); + } + } + + // server-side interface + public interface IMathService + { + void Div(DivArgs request, IObserver<DivReply> responseObserver); + + void Fib(FibArgs request, IObserver<Num> responseObserver); + + IObserver<Num> Sum(IObserver<Num> responseObserver); + + IObserver<DivArgs> DivMany(IObserver<DivReply> responseObserver); + } + + public static ServerServiceDefinition BindService(IMathService serviceImpl) + { + return ServerServiceDefinition.CreateBuilder("/math.Math/") + .AddMethod(divMethod, serviceImpl.Div) + .AddMethod(fibMethod, serviceImpl.Fib) + .AddMethod(sumMethod, serviceImpl.Sum) + .AddMethod(divManyMethod, serviceImpl.DivMany).Build(); + } + + public static IMathServiceClient NewStub(Channel channel) + { + return new MathServiceClientStub(channel); + } + } +} diff --git a/src/csharp/Grpc.Examples/MathServiceImpl.cs b/src/csharp/Grpc.Examples/MathServiceImpl.cs new file mode 100644 index 0000000000..462fab4454 --- /dev/null +++ b/src/csharp/Grpc.Examples/MathServiceImpl.cs @@ -0,0 +1,152 @@ +#region Copyright notice and license + +// 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. + +#endregion + +using System; +using System.Collections.Generic; +using System.Reactive.Linq; +using System.Threading; +using System.Threading.Tasks; +using Grpc.Core.Utils; + +namespace math +{ + /// <summary> + /// Implementation of MathService server + /// </summary> + public class MathServiceImpl : MathGrpc.IMathService + { + public void Div(DivArgs request, IObserver<DivReply> responseObserver) + { + var response = DivInternal(request); + responseObserver.OnNext(response); + responseObserver.OnCompleted(); + } + + public void Fib(FibArgs request, IObserver<Num> responseObserver) + { + if (request.Limit <= 0) + { + // TODO: support cancellation.... + throw new NotImplementedException("Not implemented yet"); + } + + if (request.Limit > 0) + { + foreach (var num in FibInternal(request.Limit)) + { + responseObserver.OnNext(num); + } + responseObserver.OnCompleted(); + } + } + + public IObserver<Num> Sum(IObserver<Num> responseObserver) + { + var recorder = new RecordingObserver<Num>(); + Task.Factory.StartNew(() => { + + List<Num> inputs = recorder.ToList().Result; + + long sum = 0; + foreach (Num num in inputs) + { + sum += num.Num_; + } + + responseObserver.OnNext(Num.CreateBuilder().SetNum_(sum).Build()); + responseObserver.OnCompleted(); + }); + return recorder; + } + + public IObserver<DivArgs> DivMany(IObserver<DivReply> responseObserver) + { + return new DivObserver(responseObserver); + } + + static DivReply DivInternal(DivArgs args) + { + long quotient = args.Dividend / args.Divisor; + long remainder = args.Dividend % args.Divisor; + return new DivReply.Builder { Quotient = quotient, Remainder = remainder }.Build(); + } + + static IEnumerable<Num> FibInternal(long n) + { + long a = 1; + yield return new Num.Builder { Num_=a }.Build(); + + long b = 1; + for (long i = 0; i < n - 1; i++) + { + long temp = a; + a = b; + b = temp + b; + yield return new Num.Builder { Num_=a }.Build(); + } + } + + private class DivObserver : IObserver<DivArgs> { + + readonly IObserver<DivReply> responseObserver; + + public DivObserver(IObserver<DivReply> responseObserver) + { + this.responseObserver = responseObserver; + } + + public void OnCompleted() + { + Task.Factory.StartNew(() => + responseObserver.OnCompleted()); + } + + public void OnError(Exception error) + { + throw new NotImplementedException(); + } + + public void OnNext(DivArgs value) + { + // TODO: currently we need this indirection because + // responseObserver waits for write to finish, this + // callback is called from grpc threadpool which + // currently only has one thread. + // Same story for OnCompleted(). + Task.Factory.StartNew(() => + responseObserver.OnNext(DivInternal(value))); + } + } + } +} + diff --git a/src/csharp/Grpc.Examples/Properties/AssemblyInfo.cs b/src/csharp/Grpc.Examples/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..7603db7ffd --- /dev/null +++ b/src/csharp/Grpc.Examples/Properties/AssemblyInfo.cs @@ -0,0 +1,22 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. +[assembly: AssemblyTitle ("Grpc.Examples")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("")] +[assembly: AssemblyCopyright ("Google Inc. All rights reserved.")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. +[assembly: AssemblyVersion ("0.1.*")] +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/src/csharp/Grpc.Examples/packages.config b/src/csharp/Grpc.Examples/packages.config new file mode 100644 index 0000000000..a6a949b3b3 --- /dev/null +++ b/src/csharp/Grpc.Examples/packages.config @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Google.ProtocolBuffers" version="2.4.1.521" targetFramework="net45" /> + <package id="Ix-Main" version="1.2.3" targetFramework="net45" /> + <package id="NUnit" version="2.6.4" targetFramework="net45" /> + <package id="Rx-Core" version="2.2.5" targetFramework="net45" /> + <package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" /> + <package id="Rx-Linq" version="2.2.5" targetFramework="net45" /> + <package id="Rx-Main" version="2.2.5" targetFramework="net45" /> + <package id="Rx-PlatformServices" version="2.2.5" targetFramework="net45" /> +</packages>
\ No newline at end of file diff --git a/src/csharp/Grpc.Examples/proto/math.proto b/src/csharp/Grpc.Examples/proto/math.proto new file mode 100644 index 0000000000..5485d580c3 --- /dev/null +++ b/src/csharp/Grpc.Examples/proto/math.proto @@ -0,0 +1,80 @@ + +// 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. + +syntax = "proto2"; + +package math; + +message DivArgs { + optional int64 dividend = 1; + optional int64 divisor = 2; +} + +message DivReply { + optional int64 quotient = 1; + optional int64 remainder = 2; +} + +message FibArgs { + optional int64 limit = 1; +} + +message Num { + optional int64 num = 1; +} + +message FibReply { + optional int64 count = 1; +} + +service Math { + // Div divides args.dividend by args.divisor and returns the quotient and + // remainder. + rpc Div (DivArgs) returns (DivReply) { + } + + // DivMany accepts an arbitrary number of division args from the client stream + // and sends back the results in the reply stream. The stream continues until + // the client closes its end; the server does the same after sending all the + // replies. The stream ends immediately if either end aborts. + rpc DivMany (stream DivArgs) returns (stream DivReply) { + } + + // Fib generates numbers in the Fibonacci sequence. If args.limit > 0, Fib + // generates up to limit numbers; otherwise it continues until the call is + // canceled. Unlike Fib above, Fib has no final FibReply. + rpc Fib (FibArgs) returns (stream Num) { + } + + // Sum sums a stream of numbers, returning the final result once the stream + // is closed. + rpc Sum (stream Num) returns (Num) { + } +} |