mirror of https://github.com/grpc/grpc.git
commit
12e111c692
909 changed files with 24936 additions and 18506 deletions
@ -0,0 +1,39 @@ |
||||
// GENERATED CODE -- DO NOT EDIT!
|
||||
|
||||
var grpc = require('grpc'); |
||||
var helloworld_pb = require('./helloworld_pb.js'); |
||||
|
||||
function serialize_HelloReply(arg) { |
||||
if (!(arg instanceof helloworld_pb.HelloReply)) { |
||||
throw new Error('Expected argument of type HelloReply'); |
||||
} |
||||
return new Buffer(arg.serializeBinary()); |
||||
} |
||||
function deserialize_HelloReply(buffer_arg) { |
||||
return helloworld_pb.HelloReply.deserializeBinary(new Uint8Array(buffer_arg)); |
||||
} |
||||
function serialize_HelloRequest(arg) { |
||||
if (!(arg instanceof helloworld_pb.HelloRequest)) { |
||||
throw new Error('Expected argument of type HelloRequest'); |
||||
} |
||||
return new Buffer(arg.serializeBinary()); |
||||
} |
||||
function deserialize_HelloRequest(buffer_arg) { |
||||
return helloworld_pb.HelloRequest.deserializeBinary(new Uint8Array(buffer_arg)); |
||||
} |
||||
|
||||
var GreeterService = exports.GreeterService = { |
||||
sayHello: { |
||||
path: '/helloworld.Greeter/SayHello', |
||||
requestStream: false, |
||||
responseStream: false, |
||||
requestType: helloworld_pb.HelloRequest, |
||||
responseType: helloworld_pb.HelloReply, |
||||
requestSerialize: serialize_HelloRequest, |
||||
requestDeserialize: deserialize_HelloRequest, |
||||
responseSerialize: serialize_HelloReply, |
||||
responseDeserialize: deserialize_HelloReply, |
||||
}, |
||||
}; |
||||
|
||||
exports.GreeterClient = grpc.makeGenericClientConstructor(GreeterService); |
@ -0,0 +1,332 @@ |
||||
/** |
||||
* @fileoverview |
||||
* @enhanceable |
||||
* @public |
||||
*/ |
||||
// GENERATED CODE -- DO NOT EDIT!
|
||||
|
||||
var jspb = require('google-protobuf'); |
||||
var goog = jspb; |
||||
var global = Function('return this')(); |
||||
|
||||
goog.exportSymbol('proto.helloworld.HelloReply', null, global); |
||||
goog.exportSymbol('proto.helloworld.HelloRequest', null, global); |
||||
|
||||
/** |
||||
* Generated by JsPbCodeGenerator. |
||||
* @param {Array=} opt_data Optional initial data array, typically from a |
||||
* server response, or constructed directly in Javascript. The array is used |
||||
* in place and becomes part of the constructed object. It is not cloned. |
||||
* If no data is provided, the constructed object will be empty, but still |
||||
* valid. |
||||
* @extends {jspb.Message} |
||||
* @constructor |
||||
*/ |
||||
proto.helloworld.HelloRequest = function(opt_data) { |
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null); |
||||
}; |
||||
goog.inherits(proto.helloworld.HelloRequest, jspb.Message); |
||||
if (goog.DEBUG && !COMPILED) { |
||||
proto.helloworld.HelloRequest.displayName = 'proto.helloworld.HelloRequest'; |
||||
} |
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) { |
||||
/** |
||||
* Creates an object representation of this proto suitable for use in Soy templates. |
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name. |
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. |
||||
* For the list of reserved names please see: |
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. |
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance |
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object} |
||||
*/ |
||||
proto.helloworld.HelloRequest.prototype.toObject = function(opt_includeInstance) { |
||||
return proto.helloworld.HelloRequest.toObject(opt_includeInstance, this); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Static version of the {@see toObject} method. |
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB |
||||
* instance for transitional soy proto support: |
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.helloworld.HelloRequest} msg The msg instance to transform. |
||||
* @return {!Object} |
||||
*/ |
||||
proto.helloworld.HelloRequest.toObject = function(includeInstance, msg) { |
||||
var f, obj = { |
||||
name: msg.getName() |
||||
}; |
||||
|
||||
if (includeInstance) { |
||||
obj.$jspbMessageInstance = msg |
||||
} |
||||
return obj; |
||||
}; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format). |
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize. |
||||
* @return {!proto.helloworld.HelloRequest} |
||||
*/ |
||||
proto.helloworld.HelloRequest.deserializeBinary = function(bytes) { |
||||
var reader = new jspb.BinaryReader(bytes); |
||||
var msg = new proto.helloworld.HelloRequest; |
||||
return proto.helloworld.HelloRequest.deserializeBinaryFromReader(msg, reader); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format) from the |
||||
* given reader into the given message object. |
||||
* @param {!proto.helloworld.HelloRequest} msg The message object to deserialize into. |
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use. |
||||
* @return {!proto.helloworld.HelloRequest} |
||||
*/ |
||||
proto.helloworld.HelloRequest.deserializeBinaryFromReader = function(msg, reader) { |
||||
while (reader.nextField()) { |
||||
if (reader.isEndGroup()) { |
||||
break; |
||||
} |
||||
var field = reader.getFieldNumber(); |
||||
switch (field) { |
||||
case 1: |
||||
var value = /** @type {string} */ (reader.readString()); |
||||
msg.setName(value); |
||||
break; |
||||
default: |
||||
reader.skipField(); |
||||
break; |
||||
} |
||||
} |
||||
return msg; |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Class method variant: serializes the given message to binary data |
||||
* (in protobuf wire format), writing to the given BinaryWriter. |
||||
* @param {!proto.helloworld.HelloRequest} message |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.helloworld.HelloRequest.serializeBinaryToWriter = function(message, writer) { |
||||
message.serializeBinaryToWriter(writer); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format). |
||||
* @return {!Uint8Array} |
||||
*/ |
||||
proto.helloworld.HelloRequest.prototype.serializeBinary = function() { |
||||
var writer = new jspb.BinaryWriter(); |
||||
this.serializeBinaryToWriter(writer); |
||||
return writer.getResultBuffer(); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format), |
||||
* writing to the given BinaryWriter. |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.helloworld.HelloRequest.prototype.serializeBinaryToWriter = function (writer) { |
||||
var f = undefined; |
||||
f = this.getName(); |
||||
if (f.length > 0) { |
||||
writer.writeString( |
||||
1, |
||||
f |
||||
); |
||||
} |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Creates a deep clone of this proto. No data is shared with the original. |
||||
* @return {!proto.helloworld.HelloRequest} The clone. |
||||
*/ |
||||
proto.helloworld.HelloRequest.prototype.cloneMessage = function() { |
||||
return /** @type {!proto.helloworld.HelloRequest} */ (jspb.Message.cloneMessage(this)); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* optional string name = 1; |
||||
* @return {string} |
||||
*/ |
||||
proto.helloworld.HelloRequest.prototype.getName = function() { |
||||
return /** @type {string} */ (jspb.Message.getFieldProto3(this, 1, "")); |
||||
}; |
||||
|
||||
|
||||
/** @param {string} value */ |
||||
proto.helloworld.HelloRequest.prototype.setName = function(value) { |
||||
jspb.Message.setField(this, 1, value); |
||||
}; |
||||
|
||||
|
||||
|
||||
/** |
||||
* Generated by JsPbCodeGenerator. |
||||
* @param {Array=} opt_data Optional initial data array, typically from a |
||||
* server response, or constructed directly in Javascript. The array is used |
||||
* in place and becomes part of the constructed object. It is not cloned. |
||||
* If no data is provided, the constructed object will be empty, but still |
||||
* valid. |
||||
* @extends {jspb.Message} |
||||
* @constructor |
||||
*/ |
||||
proto.helloworld.HelloReply = function(opt_data) { |
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null); |
||||
}; |
||||
goog.inherits(proto.helloworld.HelloReply, jspb.Message); |
||||
if (goog.DEBUG && !COMPILED) { |
||||
proto.helloworld.HelloReply.displayName = 'proto.helloworld.HelloReply'; |
||||
} |
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) { |
||||
/** |
||||
* Creates an object representation of this proto suitable for use in Soy templates. |
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name. |
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. |
||||
* For the list of reserved names please see: |
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. |
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance |
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object} |
||||
*/ |
||||
proto.helloworld.HelloReply.prototype.toObject = function(opt_includeInstance) { |
||||
return proto.helloworld.HelloReply.toObject(opt_includeInstance, this); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Static version of the {@see toObject} method. |
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB |
||||
* instance for transitional soy proto support: |
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.helloworld.HelloReply} msg The msg instance to transform. |
||||
* @return {!Object} |
||||
*/ |
||||
proto.helloworld.HelloReply.toObject = function(includeInstance, msg) { |
||||
var f, obj = { |
||||
message: msg.getMessage() |
||||
}; |
||||
|
||||
if (includeInstance) { |
||||
obj.$jspbMessageInstance = msg |
||||
} |
||||
return obj; |
||||
}; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format). |
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize. |
||||
* @return {!proto.helloworld.HelloReply} |
||||
*/ |
||||
proto.helloworld.HelloReply.deserializeBinary = function(bytes) { |
||||
var reader = new jspb.BinaryReader(bytes); |
||||
var msg = new proto.helloworld.HelloReply; |
||||
return proto.helloworld.HelloReply.deserializeBinaryFromReader(msg, reader); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format) from the |
||||
* given reader into the given message object. |
||||
* @param {!proto.helloworld.HelloReply} msg The message object to deserialize into. |
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use. |
||||
* @return {!proto.helloworld.HelloReply} |
||||
*/ |
||||
proto.helloworld.HelloReply.deserializeBinaryFromReader = function(msg, reader) { |
||||
while (reader.nextField()) { |
||||
if (reader.isEndGroup()) { |
||||
break; |
||||
} |
||||
var field = reader.getFieldNumber(); |
||||
switch (field) { |
||||
case 1: |
||||
var value = /** @type {string} */ (reader.readString()); |
||||
msg.setMessage(value); |
||||
break; |
||||
default: |
||||
reader.skipField(); |
||||
break; |
||||
} |
||||
} |
||||
return msg; |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Class method variant: serializes the given message to binary data |
||||
* (in protobuf wire format), writing to the given BinaryWriter. |
||||
* @param {!proto.helloworld.HelloReply} message |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.helloworld.HelloReply.serializeBinaryToWriter = function(message, writer) { |
||||
message.serializeBinaryToWriter(writer); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format). |
||||
* @return {!Uint8Array} |
||||
*/ |
||||
proto.helloworld.HelloReply.prototype.serializeBinary = function() { |
||||
var writer = new jspb.BinaryWriter(); |
||||
this.serializeBinaryToWriter(writer); |
||||
return writer.getResultBuffer(); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format), |
||||
* writing to the given BinaryWriter. |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.helloworld.HelloReply.prototype.serializeBinaryToWriter = function (writer) { |
||||
var f = undefined; |
||||
f = this.getMessage(); |
||||
if (f.length > 0) { |
||||
writer.writeString( |
||||
1, |
||||
f |
||||
); |
||||
} |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Creates a deep clone of this proto. No data is shared with the original. |
||||
* @return {!proto.helloworld.HelloReply} The clone. |
||||
*/ |
||||
proto.helloworld.HelloReply.prototype.cloneMessage = function() { |
||||
return /** @type {!proto.helloworld.HelloReply} */ (jspb.Message.cloneMessage(this)); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* optional string message = 1; |
||||
* @return {string} |
||||
*/ |
||||
proto.helloworld.HelloReply.prototype.getMessage = function() { |
||||
return /** @type {string} */ (jspb.Message.getFieldProto3(this, 1, "")); |
||||
}; |
||||
|
||||
|
||||
/** @param {string} value */ |
||||
proto.helloworld.HelloReply.prototype.setMessage = function(value) { |
||||
jspb.Message.setField(this, 1, value); |
||||
}; |
||||
|
||||
|
||||
goog.object.extend(exports, proto.helloworld); |
@ -1,7 +1,8 @@ |
||||
# GRPC Python setup requirements |
||||
coverage>=4.0 |
||||
cython>=0.23 |
||||
enum34>=1.0.4 |
||||
futures>=2.2.0 |
||||
cython>=0.23 |
||||
coverage>=4.0 |
||||
protobuf>=3.0.0a3 |
||||
six>=1.10 |
||||
wheel>=0.29 |
@ -0,0 +1,277 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, 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. |
||||
* |
||||
*/ |
||||
|
||||
#include <map> |
||||
|
||||
#include "src/compiler/config.h" |
||||
#include "src/compiler/generator_helpers.h" |
||||
#include "src/compiler/node_generator_helpers.h" |
||||
|
||||
using grpc::protobuf::FileDescriptor; |
||||
using grpc::protobuf::ServiceDescriptor; |
||||
using grpc::protobuf::MethodDescriptor; |
||||
using grpc::protobuf::Descriptor; |
||||
using grpc::protobuf::io::Printer; |
||||
using grpc::protobuf::io::StringOutputStream; |
||||
using std::map; |
||||
|
||||
namespace grpc_node_generator { |
||||
namespace { |
||||
|
||||
// Returns the alias we assign to the module of the given .proto filename
|
||||
// when importing. Copied entirely from
|
||||
// github:google/protobuf/src/google/protobuf/compiler/js/js_generator.cc#L154
|
||||
grpc::string ModuleAlias(const grpc::string filename) { |
||||
// This scheme could technically cause problems if a file includes any 2 of:
|
||||
// foo/bar_baz.proto
|
||||
// foo_bar_baz.proto
|
||||
// foo_bar/baz.proto
|
||||
//
|
||||
// We'll worry about this problem if/when we actually see it. This name isn't
|
||||
// exposed to users so we can change it later if we need to.
|
||||
grpc::string basename = grpc_generator::StripProto(filename); |
||||
basename = grpc_generator::StringReplace(basename, "-", "$"); |
||||
basename = grpc_generator::StringReplace(basename, "/", "_"); |
||||
return basename + "_pb"; |
||||
} |
||||
|
||||
// Given a filename like foo/bar/baz.proto, returns the corresponding JavaScript
|
||||
// message file foo/bar/baz.js
|
||||
grpc::string GetJSMessageFilename(const grpc::string& filename) { |
||||
grpc::string name = filename; |
||||
return grpc_generator::StripProto(name) + "_pb.js"; |
||||
} |
||||
|
||||
// Given a filename like foo/bar/baz.proto, returns the root directory
|
||||
// path ../../
|
||||
grpc::string GetRootPath(const grpc::string& filename) { |
||||
size_t slashes = std::count(filename.begin(), filename.end(), '/'); |
||||
if (slashes == 0) { |
||||
return "./"; |
||||
} |
||||
grpc::string result = ""; |
||||
for (size_t i = 0; i < slashes; i++) { |
||||
result += "../"; |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
// Return the relative path to load to_file from the directory containing
|
||||
// from_file, assuming that both paths are relative to the same directory
|
||||
grpc::string GetRelativePath(const grpc::string& from_file, |
||||
const grpc::string& to_file) { |
||||
return GetRootPath(from_file) + to_file; |
||||
} |
||||
|
||||
/* Finds all message types used in all services in the file, and returns them
|
||||
* as a map of fully qualified message type name to message descriptor */ |
||||
map<grpc::string, const Descriptor*> GetAllMessages(const FileDescriptor *file) { |
||||
map<grpc::string, const Descriptor*> message_types; |
||||
for (int service_num = 0; service_num < file->service_count(); service_num++) { |
||||
const ServiceDescriptor* service = file->service(service_num); |
||||
for (int method_num = 0; method_num < service->method_count(); method_num++) { |
||||
const MethodDescriptor* method = service->method(method_num); |
||||
const Descriptor* input_type = method->input_type(); |
||||
const Descriptor* output_type = method->output_type(); |
||||
message_types[input_type->name()] = input_type; |
||||
message_types[output_type->name()] = output_type; |
||||
} |
||||
} |
||||
return message_types; |
||||
} |
||||
|
||||
grpc::string MessageIdentifierName(const grpc::string& name) { |
||||
return grpc_generator::StringReplace(name, ".", "_"); |
||||
} |
||||
|
||||
grpc::string NodeObjectPath(const Descriptor *descriptor) { |
||||
grpc::string module_alias = ModuleAlias(descriptor->file()->name()); |
||||
grpc::string name = descriptor->name(); |
||||
grpc_generator::StripPrefix(&name, descriptor->file()->package() + "."); |
||||
return module_alias + "." + name; |
||||
} |
||||
|
||||
// Prints out the message serializer and deserializer functions
|
||||
void PrintMessageTransformer(const Descriptor *descriptor, Printer *out) { |
||||
map<grpc::string, grpc::string> template_vars; |
||||
template_vars["identifier_name"] = MessageIdentifierName(descriptor->name()); |
||||
template_vars["name"] = descriptor->name(); |
||||
template_vars["node_name"] = NodeObjectPath(descriptor); |
||||
// Print the serializer
|
||||
out->Print(template_vars, "function serialize_$identifier_name$(arg) {\n"); |
||||
out->Indent(); |
||||
out->Print(template_vars, "if (!(arg instanceof $node_name$)) {\n"); |
||||
out->Indent(); |
||||
out->Print(template_vars, |
||||
"throw new Error('Expected argument of type $name$');\n"); |
||||
out->Outdent(); |
||||
out->Print("}\n"); |
||||
out->Print("return new Buffer(arg.serializeBinary());\n"); |
||||
out->Outdent(); |
||||
out->Print("}\n\n"); |
||||
|
||||
// Print the deserializer
|
||||
out->Print(template_vars, |
||||
"function deserialize_$identifier_name$(buffer_arg) {\n"); |
||||
out->Indent(); |
||||
out->Print( |
||||
template_vars, |
||||
"return $node_name$.deserializeBinary(new Uint8Array(buffer_arg));\n"); |
||||
out->Outdent(); |
||||
out->Print("}\n\n"); |
||||
} |
||||
|
||||
void PrintMethod(const MethodDescriptor *method, Printer *out) { |
||||
const Descriptor *input_type = method->input_type(); |
||||
const Descriptor *output_type = method->output_type(); |
||||
map<grpc::string, grpc::string> vars; |
||||
vars["service_name"] = method->service()->full_name(); |
||||
vars["name"] = method->name(); |
||||
vars["input_type"] = NodeObjectPath(input_type); |
||||
vars["input_type_id"] = MessageIdentifierName(input_type->name()); |
||||
vars["output_type"] = NodeObjectPath(output_type); |
||||
vars["output_type_id"] = MessageIdentifierName(output_type->name()); |
||||
vars["client_stream"] = method->client_streaming() ? "true" : "false"; |
||||
vars["server_stream"] = method->server_streaming() ? "true" : "false"; |
||||
out->Print("{\n"); |
||||
out->Indent(); |
||||
out->Print(vars, "path: '/$service_name$/$name$',\n"); |
||||
out->Print(vars, "requestStream: $client_stream$,\n"); |
||||
out->Print(vars, "responseStream: $server_stream$,\n"); |
||||
out->Print(vars, "requestType: $input_type$,\n"); |
||||
out->Print(vars, "responseType: $output_type$,\n"); |
||||
out->Print(vars, "requestSerialize: serialize_$input_type_id$,\n"); |
||||
out->Print(vars, "requestDeserialize: deserialize_$input_type_id$,\n"); |
||||
out->Print(vars, "responseSerialize: serialize_$output_type_id$,\n"); |
||||
out->Print(vars, "responseDeserialize: deserialize_$output_type_id$,\n"); |
||||
out->Outdent(); |
||||
out->Print("}"); |
||||
} |
||||
|
||||
// Prints out the service descriptor object
|
||||
void PrintService(const ServiceDescriptor *service, Printer *out) { |
||||
map<grpc::string, grpc::string> template_vars; |
||||
template_vars["name"] = service->name(); |
||||
out->Print(template_vars, "var $name$Service = exports.$name$Service = {\n"); |
||||
out->Indent(); |
||||
for (int i = 0; i < service->method_count(); i++) { |
||||
grpc::string method_name = grpc_generator::LowercaseFirstLetter( |
||||
service->method(i)->name()); |
||||
out->Print("$method_name$: ", |
||||
"method_name", method_name); |
||||
PrintMethod(service->method(i), out); |
||||
out->Print(",\n"); |
||||
} |
||||
out->Outdent(); |
||||
out->Print("};\n\n"); |
||||
out->Print(template_vars, "exports.$name$Client = " |
||||
"grpc.makeGenericClientConstructor($name$Service);\n"); |
||||
} |
||||
|
||||
} |
||||
|
||||
grpc::string GetImports(const FileDescriptor *file) { |
||||
grpc::string output; |
||||
{ |
||||
StringOutputStream output_stream(&output); |
||||
Printer out(&output_stream, '$'); |
||||
|
||||
if (file->service_count() == 0) { |
||||
return output; |
||||
} |
||||
|
||||
out.Print("// GENERATED CODE -- DO NOT EDIT!\n\n"); |
||||
|
||||
out.Print("'use strict';\n"); |
||||
|
||||
out.Print("var grpc = require('grpc');\n"); |
||||
if (file->message_type_count() > 0) { |
||||
grpc::string file_path = GetRelativePath(file->name(), |
||||
GetJSMessageFilename( |
||||
file->name())); |
||||
out.Print("var $module_alias$ = require('$file_path$');\n", |
||||
"module_alias", ModuleAlias(file->name()), |
||||
"file_path", file_path); |
||||
} |
||||
|
||||
for (int i = 0; i < file->dependency_count(); i++) { |
||||
grpc::string file_path = GetRelativePath( |
||||
file->name(), GetJSMessageFilename(file->dependency(i)->name())); |
||||
out.Print("var $module_alias$ = require('$file_path$');\n", |
||||
"module_alias", ModuleAlias(file->dependency(i)->name()), |
||||
"file_path", file_path); |
||||
} |
||||
out.Print("\n"); |
||||
} |
||||
return output; |
||||
} |
||||
|
||||
grpc::string GetTransformers(const FileDescriptor *file) { |
||||
grpc::string output; |
||||
{ |
||||
StringOutputStream output_stream(&output); |
||||
Printer out(&output_stream, '$'); |
||||
|
||||
if (file->service_count() == 0) { |
||||
return output; |
||||
} |
||||
|
||||
map<grpc::string, const Descriptor*> messages = GetAllMessages(file); |
||||
for (std::map<grpc::string, const Descriptor*>::iterator it = |
||||
messages.begin(); |
||||
it != messages.end(); it++) { |
||||
PrintMessageTransformer(it->second, &out); |
||||
} |
||||
out.Print("\n"); |
||||
} |
||||
return output; |
||||
} |
||||
|
||||
grpc::string GetServices(const FileDescriptor *file) { |
||||
grpc::string output; |
||||
{ |
||||
StringOutputStream output_stream(&output); |
||||
Printer out(&output_stream, '$'); |
||||
|
||||
if (file->service_count() == 0) { |
||||
return output; |
||||
} |
||||
|
||||
for (int i = 0; i < file->service_count(); i++) { |
||||
PrintService(file->service(i), &out); |
||||
} |
||||
} |
||||
return output; |
||||
} |
||||
|
||||
} // namespace grpc_node_generator
|
@ -0,0 +1,49 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, 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 GRPC_INTERNAL_COMPILER_NODE_GENERATOR_H |
||||
#define GRPC_INTERNAL_COMPILER_NODE_GENERATOR_H |
||||
|
||||
#include "src/compiler/config.h" |
||||
|
||||
namespace grpc_node_generator { |
||||
|
||||
grpc::string GetImports(const grpc::protobuf::FileDescriptor *file); |
||||
|
||||
grpc::string GetTransformers(const grpc::protobuf::FileDescriptor *file); |
||||
|
||||
grpc::string GetServices(const grpc::protobuf::FileDescriptor *file); |
||||
|
||||
} // namespace grpc_node_generator
|
||||
|
||||
#endif // GRPC_INTERNAL_COMPILER_NODE_GENERATOR_H
|
@ -0,0 +1,50 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, 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 GRPC_INTERNAL_COMPILER_NODE_GENERATOR_HELPERS_H |
||||
#define GRPC_INTERNAL_COMPILER_NODE_GENERATOR_HELPERS_H |
||||
|
||||
#include <algorithm> |
||||
|
||||
#include "src/compiler/config.h" |
||||
#include "src/compiler/generator_helpers.h" |
||||
|
||||
namespace grpc_node_generator { |
||||
|
||||
inline grpc::string GetJSServiceFilename(const grpc::string& filename) { |
||||
return grpc_generator::StripProto(filename) + "_grpc_pb.js"; |
||||
} |
||||
|
||||
} // namespace grpc_node_generator
|
||||
|
||||
#endif // GRPC_INTERNAL_COMPILER_NODE_GENERATOR_HELPERS_H
|
@ -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. |
||||
* |
||||
*/ |
||||
|
||||
// Generates Node gRPC service interface out of Protobuf IDL.
|
||||
|
||||
#include <memory> |
||||
|
||||
#include "src/compiler/config.h" |
||||
#include "src/compiler/node_generator.h" |
||||
#include "src/compiler/node_generator_helpers.h" |
||||
|
||||
using grpc_node_generator::GetImports; |
||||
using grpc_node_generator::GetJSServiceFilename; |
||||
using grpc_node_generator::GetServices; |
||||
using grpc_node_generator::GetTransformers; |
||||
|
||||
class NodeGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator { |
||||
public: |
||||
NodeGrpcGenerator() {} |
||||
~NodeGrpcGenerator() {} |
||||
|
||||
bool Generate(const grpc::protobuf::FileDescriptor *file, |
||||
const grpc::string ¶meter, |
||||
grpc::protobuf::compiler::GeneratorContext *context, |
||||
grpc::string *error) const { |
||||
grpc::string code = GetImports(file) + |
||||
GetTransformers(file) + |
||||
GetServices(file); |
||||
if (code.size() == 0) { |
||||
return true; |
||||
} |
||||
|
||||
// Get output file name
|
||||
grpc::string file_name = GetJSServiceFilename(file->name()); |
||||
|
||||
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> output( |
||||
context->Open(file_name)); |
||||
grpc::protobuf::io::CodedOutputStream coded_out(output.get()); |
||||
coded_out.WriteRaw(code.data(), code.size()); |
||||
return true; |
||||
} |
||||
}; |
||||
|
||||
int main(int argc, char *argv[]) { |
||||
NodeGrpcGenerator generator; |
||||
return grpc::protobuf::compiler::PluginMain(argc, argv, &generator); |
||||
} |
@ -0,0 +1,94 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, 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. |
||||
* |
||||
*/ |
||||
|
||||
/* Posix code for gpr snprintf support. */ |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#ifdef GPR_WIN32 |
||||
|
||||
/* Some platforms (namely msys) need wchar to be included BEFORE
|
||||
anything else, especially strsafe.h. */ |
||||
#include <wchar.h> |
||||
|
||||
#include <stdarg.h> |
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
#include <strsafe.h> |
||||
|
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/string_util.h> |
||||
|
||||
#include "src/core/lib/support/string.h" |
||||
|
||||
#if defined UNICODE || defined _UNICODE |
||||
LPTSTR |
||||
gpr_char_to_tchar(LPCSTR input) { |
||||
LPTSTR ret; |
||||
int needed = MultiByteToWideChar(CP_UTF8, 0, input, -1, NULL, 0); |
||||
if (needed <= 0) return NULL; |
||||
ret = gpr_malloc((unsigned)needed * sizeof(TCHAR)); |
||||
MultiByteToWideChar(CP_UTF8, 0, input, -1, ret, needed); |
||||
return ret; |
||||
} |
||||
|
||||
LPSTR |
||||
gpr_tchar_to_char(LPCTSTR input) { |
||||
LPSTR ret; |
||||
int needed = WideCharToMultiByte(CP_UTF8, 0, input, -1, NULL, 0, NULL, NULL); |
||||
if (needed <= 0) return NULL; |
||||
ret = gpr_malloc((unsigned)needed); |
||||
WideCharToMultiByte(CP_UTF8, 0, input, -1, ret, needed, NULL, NULL); |
||||
return ret; |
||||
} |
||||
#else |
||||
char *gpr_tchar_to_char(LPTSTR input) { return gpr_strdup(input); } |
||||
|
||||
char *gpr_char_to_tchar(LPTSTR input) { return gpr_strdup(input); } |
||||
#endif |
||||
|
||||
char *gpr_format_message(int messageid) { |
||||
LPTSTR tmessage; |
||||
char *message; |
||||
DWORD status = FormatMessage( |
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | |
||||
FORMAT_MESSAGE_IGNORE_INSERTS, |
||||
NULL, (DWORD)messageid, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
||||
(LPTSTR)(&tmessage), 0, NULL); |
||||
if (status == 0) return gpr_strdup("Unable to retrieve error string"); |
||||
message = gpr_tchar_to_char(tmessage); |
||||
LocalFree(tmessage); |
||||
return message; |
||||
} |
||||
|
||||
#endif /* GPR_WIN32 */ |
@ -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. |
||||
* |
||||
*/ |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#ifdef GPR_MSYS_TMPFILE |
||||
|
||||
#include <io.h> |
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
#include <tchar.h> |
||||
|
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/string_util.h> |
||||
|
||||
#include "src/core/lib/support/string_win32.h" |
||||
#include "src/core/lib/support/tmpfile.h" |
||||
|
||||
FILE *gpr_tmpfile(const char *prefix, char **tmp_filename_out) { |
||||
FILE *result = NULL; |
||||
char tmp_filename[MAX_PATH]; |
||||
UINT success; |
||||
|
||||
if (tmp_filename_out != NULL) *tmp_filename_out = NULL; |
||||
|
||||
/* Generate a unique filename with our template + temporary path. */ |
||||
success = GetTempFileNameA(".", prefix, 0, tmp_filename); |
||||
fprintf(stderr, "success = %d\n", success); |
||||
|
||||
if (success) { |
||||
/* Open a file there. */ |
||||
result = fopen(tmp_filename, "wb+"); |
||||
fprintf(stderr, "result = %p\n", result); |
||||
} |
||||
if (result != NULL && tmp_filename_out) { |
||||
*tmp_filename_out = gpr_strdup(tmp_filename); |
||||
} |
||||
|
||||
return result; |
||||
} |
||||
|
||||
#endif /* GPR_MSYS_TMPFILE */ |
@ -0,0 +1,3 @@ |
||||
bin |
||||
obj |
||||
|
@ -0,0 +1,60 @@ |
||||
<?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> |
||||
<ProjectGuid>{ADEBA147-80AE-4710-82E9-5B7F93690266}</ProjectGuid> |
||||
<OutputType>Exe</OutputType> |
||||
<RootNamespace>Grpc.IntegrationTesting.StressClient</RootNamespace> |
||||
<AssemblyName>Grpc.IntegrationTesting.StressClient</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> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
<DebugType>pdbonly</DebugType> |
||||
<Optimize>true</Optimize> |
||||
<OutputPath>bin\Release</OutputPath> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseSigned|AnyCPU' "> |
||||
<DebugType>pdbonly</DebugType> |
||||
<Optimize>true</Optimize> |
||||
<OutputPath>bin\ReleaseSigned</OutputPath> |
||||
<ErrorReport>prompt</ErrorReport> |
||||
<WarningLevel>4</WarningLevel> |
||||
<SignAssembly>True</SignAssembly> |
||||
<AssemblyOriginatorKeyFile>..\keys\Grpc.snk</AssemblyOriginatorKeyFile> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="..\Grpc.Core\Version.cs"> |
||||
<Link>Version.cs</Link> |
||||
</Compile> |
||||
<Compile Include="Program.cs" /> |
||||
<Compile Include="Properties\AssemblyInfo.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> |
||||
<ProjectReference Include="..\Grpc.IntegrationTesting\Grpc.IntegrationTesting.csproj"> |
||||
<Project>{C61154BA-DD4A-4838-8420-0162A28925E0}</Project> |
||||
<Name>Grpc.IntegrationTesting</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
</Project> |
@ -0,0 +1,452 @@ |
||||
// Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
// source: src/proto/grpc/testing/metrics.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 Grpc.Testing { |
||||
|
||||
/// <summary>Holder for reflection information generated from src/proto/grpc/testing/metrics.proto</summary> |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
public static partial class MetricsReflection { |
||||
|
||||
#region Descriptor |
||||
/// <summary>File descriptor for src/proto/grpc/testing/metrics.proto</summary> |
||||
public static pbr::FileDescriptor Descriptor { |
||||
get { return descriptor; } |
||||
} |
||||
private static pbr::FileDescriptor descriptor; |
||||
|
||||
static MetricsReflection() { |
||||
byte[] descriptorData = global::System.Convert.FromBase64String( |
||||
string.Concat( |
||||
"CiRzcmMvcHJvdG8vZ3JwYy90ZXN0aW5nL21ldHJpY3MucHJvdG8SDGdycGMu", |
||||
"dGVzdGluZyJsCg1HYXVnZVJlc3BvbnNlEgwKBG5hbWUYASABKAkSFAoKbG9u", |
||||
"Z192YWx1ZRgCIAEoA0gAEhYKDGRvdWJsZV92YWx1ZRgDIAEoAUgAEhYKDHN0", |
||||
"cmluZ192YWx1ZRgEIAEoCUgAQgcKBXZhbHVlIhwKDEdhdWdlUmVxdWVzdBIM", |
||||
"CgRuYW1lGAEgASgJIg4KDEVtcHR5TWVzc2FnZTKgAQoOTWV0cmljc1NlcnZp", |
||||
"Y2USSQoMR2V0QWxsR2F1Z2VzEhouZ3JwYy50ZXN0aW5nLkVtcHR5TWVzc2Fn", |
||||
"ZRobLmdycGMudGVzdGluZy5HYXVnZVJlc3BvbnNlMAESQwoIR2V0R2F1Z2US", |
||||
"Gi5ncnBjLnRlc3RpbmcuR2F1Z2VSZXF1ZXN0GhsuZ3JwYy50ZXN0aW5nLkdh", |
||||
"dWdlUmVzcG9uc2ViBnByb3RvMw==")); |
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, |
||||
new pbr::FileDescriptor[] { }, |
||||
new pbr::GeneratedCodeInfo(null, new pbr::GeneratedCodeInfo[] { |
||||
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.GaugeResponse), global::Grpc.Testing.GaugeResponse.Parser, new[]{ "Name", "LongValue", "DoubleValue", "StringValue" }, new[]{ "Value" }, null, null), |
||||
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.GaugeRequest), global::Grpc.Testing.GaugeRequest.Parser, new[]{ "Name" }, null, null, null), |
||||
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.EmptyMessage), global::Grpc.Testing.EmptyMessage.Parser, null, null, null, null) |
||||
})); |
||||
} |
||||
#endregion |
||||
|
||||
} |
||||
#region Messages |
||||
/// <summary> |
||||
/// Reponse message containing the gauge name and value |
||||
/// </summary> |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
public sealed partial class GaugeResponse : pb::IMessage<GaugeResponse> { |
||||
private static readonly pb::MessageParser<GaugeResponse> _parser = new pb::MessageParser<GaugeResponse>(() => new GaugeResponse()); |
||||
public static pb::MessageParser<GaugeResponse> Parser { get { return _parser; } } |
||||
|
||||
public static pbr::MessageDescriptor Descriptor { |
||||
get { return global::Grpc.Testing.MetricsReflection.Descriptor.MessageTypes[0]; } |
||||
} |
||||
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor { |
||||
get { return Descriptor; } |
||||
} |
||||
|
||||
public GaugeResponse() { |
||||
OnConstruction(); |
||||
} |
||||
|
||||
partial void OnConstruction(); |
||||
|
||||
public GaugeResponse(GaugeResponse other) : this() { |
||||
name_ = other.name_; |
||||
switch (other.ValueCase) { |
||||
case ValueOneofCase.LongValue: |
||||
LongValue = other.LongValue; |
||||
break; |
||||
case ValueOneofCase.DoubleValue: |
||||
DoubleValue = other.DoubleValue; |
||||
break; |
||||
case ValueOneofCase.StringValue: |
||||
StringValue = other.StringValue; |
||||
break; |
||||
} |
||||
|
||||
} |
||||
|
||||
public GaugeResponse Clone() { |
||||
return new GaugeResponse(this); |
||||
} |
||||
|
||||
/// <summary>Field number for the "name" field.</summary> |
||||
public const int NameFieldNumber = 1; |
||||
private string name_ = ""; |
||||
public string Name { |
||||
get { return name_; } |
||||
set { |
||||
name_ = pb::Preconditions.CheckNotNull(value, "value"); |
||||
} |
||||
} |
||||
|
||||
/// <summary>Field number for the "long_value" field.</summary> |
||||
public const int LongValueFieldNumber = 2; |
||||
public long LongValue { |
||||
get { return valueCase_ == ValueOneofCase.LongValue ? (long) value_ : 0L; } |
||||
set { |
||||
value_ = value; |
||||
valueCase_ = ValueOneofCase.LongValue; |
||||
} |
||||
} |
||||
|
||||
/// <summary>Field number for the "double_value" field.</summary> |
||||
public const int DoubleValueFieldNumber = 3; |
||||
public double DoubleValue { |
||||
get { return valueCase_ == ValueOneofCase.DoubleValue ? (double) value_ : 0D; } |
||||
set { |
||||
value_ = value; |
||||
valueCase_ = ValueOneofCase.DoubleValue; |
||||
} |
||||
} |
||||
|
||||
/// <summary>Field number for the "string_value" field.</summary> |
||||
public const int StringValueFieldNumber = 4; |
||||
public string StringValue { |
||||
get { return valueCase_ == ValueOneofCase.StringValue ? (string) value_ : ""; } |
||||
set { |
||||
value_ = pb::Preconditions.CheckNotNull(value, "value"); |
||||
valueCase_ = ValueOneofCase.StringValue; |
||||
} |
||||
} |
||||
|
||||
private object value_; |
||||
/// <summary>Enum of possible cases for the "value" oneof.</summary> |
||||
public enum ValueOneofCase { |
||||
None = 0, |
||||
LongValue = 2, |
||||
DoubleValue = 3, |
||||
StringValue = 4, |
||||
} |
||||
private ValueOneofCase valueCase_ = ValueOneofCase.None; |
||||
public ValueOneofCase ValueCase { |
||||
get { return valueCase_; } |
||||
} |
||||
|
||||
public void ClearValue() { |
||||
valueCase_ = ValueOneofCase.None; |
||||
value_ = null; |
||||
} |
||||
|
||||
public override bool Equals(object other) { |
||||
return Equals(other as GaugeResponse); |
||||
} |
||||
|
||||
public bool Equals(GaugeResponse other) { |
||||
if (ReferenceEquals(other, null)) { |
||||
return false; |
||||
} |
||||
if (ReferenceEquals(other, this)) { |
||||
return true; |
||||
} |
||||
if (Name != other.Name) return false; |
||||
if (LongValue != other.LongValue) return false; |
||||
if (DoubleValue != other.DoubleValue) return false; |
||||
if (StringValue != other.StringValue) return false; |
||||
if (ValueCase != other.ValueCase) return false; |
||||
return true; |
||||
} |
||||
|
||||
public override int GetHashCode() { |
||||
int hash = 1; |
||||
if (Name.Length != 0) hash ^= Name.GetHashCode(); |
||||
if (valueCase_ == ValueOneofCase.LongValue) hash ^= LongValue.GetHashCode(); |
||||
if (valueCase_ == ValueOneofCase.DoubleValue) hash ^= DoubleValue.GetHashCode(); |
||||
if (valueCase_ == ValueOneofCase.StringValue) hash ^= StringValue.GetHashCode(); |
||||
hash ^= (int) valueCase_; |
||||
return hash; |
||||
} |
||||
|
||||
public override string ToString() { |
||||
return pb::JsonFormatter.ToDiagnosticString(this); |
||||
} |
||||
|
||||
public void WriteTo(pb::CodedOutputStream output) { |
||||
if (Name.Length != 0) { |
||||
output.WriteRawTag(10); |
||||
output.WriteString(Name); |
||||
} |
||||
if (valueCase_ == ValueOneofCase.LongValue) { |
||||
output.WriteRawTag(16); |
||||
output.WriteInt64(LongValue); |
||||
} |
||||
if (valueCase_ == ValueOneofCase.DoubleValue) { |
||||
output.WriteRawTag(25); |
||||
output.WriteDouble(DoubleValue); |
||||
} |
||||
if (valueCase_ == ValueOneofCase.StringValue) { |
||||
output.WriteRawTag(34); |
||||
output.WriteString(StringValue); |
||||
} |
||||
} |
||||
|
||||
public int CalculateSize() { |
||||
int size = 0; |
||||
if (Name.Length != 0) { |
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); |
||||
} |
||||
if (valueCase_ == ValueOneofCase.LongValue) { |
||||
size += 1 + pb::CodedOutputStream.ComputeInt64Size(LongValue); |
||||
} |
||||
if (valueCase_ == ValueOneofCase.DoubleValue) { |
||||
size += 1 + 8; |
||||
} |
||||
if (valueCase_ == ValueOneofCase.StringValue) { |
||||
size += 1 + pb::CodedOutputStream.ComputeStringSize(StringValue); |
||||
} |
||||
return size; |
||||
} |
||||
|
||||
public void MergeFrom(GaugeResponse other) { |
||||
if (other == null) { |
||||
return; |
||||
} |
||||
if (other.Name.Length != 0) { |
||||
Name = other.Name; |
||||
} |
||||
switch (other.ValueCase) { |
||||
case ValueOneofCase.LongValue: |
||||
LongValue = other.LongValue; |
||||
break; |
||||
case ValueOneofCase.DoubleValue: |
||||
DoubleValue = other.DoubleValue; |
||||
break; |
||||
case ValueOneofCase.StringValue: |
||||
StringValue = other.StringValue; |
||||
break; |
||||
} |
||||
|
||||
} |
||||
|
||||
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; |
||||
} |
||||
case 16: { |
||||
LongValue = input.ReadInt64(); |
||||
break; |
||||
} |
||||
case 25: { |
||||
DoubleValue = input.ReadDouble(); |
||||
break; |
||||
} |
||||
case 34: { |
||||
StringValue = input.ReadString(); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
/// <summary> |
||||
/// Request message containing the gauge name |
||||
/// </summary> |
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
public sealed partial class GaugeRequest : pb::IMessage<GaugeRequest> { |
||||
private static readonly pb::MessageParser<GaugeRequest> _parser = new pb::MessageParser<GaugeRequest>(() => new GaugeRequest()); |
||||
public static pb::MessageParser<GaugeRequest> Parser { get { return _parser; } } |
||||
|
||||
public static pbr::MessageDescriptor Descriptor { |
||||
get { return global::Grpc.Testing.MetricsReflection.Descriptor.MessageTypes[1]; } |
||||
} |
||||
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor { |
||||
get { return Descriptor; } |
||||
} |
||||
|
||||
public GaugeRequest() { |
||||
OnConstruction(); |
||||
} |
||||
|
||||
partial void OnConstruction(); |
||||
|
||||
public GaugeRequest(GaugeRequest other) : this() { |
||||
name_ = other.name_; |
||||
} |
||||
|
||||
public GaugeRequest Clone() { |
||||
return new GaugeRequest(this); |
||||
} |
||||
|
||||
/// <summary>Field number for the "name" field.</summary> |
||||
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 GaugeRequest); |
||||
} |
||||
|
||||
public bool Equals(GaugeRequest 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.ToDiagnosticString(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(GaugeRequest 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 EmptyMessage : pb::IMessage<EmptyMessage> { |
||||
private static readonly pb::MessageParser<EmptyMessage> _parser = new pb::MessageParser<EmptyMessage>(() => new EmptyMessage()); |
||||
public static pb::MessageParser<EmptyMessage> Parser { get { return _parser; } } |
||||
|
||||
public static pbr::MessageDescriptor Descriptor { |
||||
get { return global::Grpc.Testing.MetricsReflection.Descriptor.MessageTypes[2]; } |
||||
} |
||||
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor { |
||||
get { return Descriptor; } |
||||
} |
||||
|
||||
public EmptyMessage() { |
||||
OnConstruction(); |
||||
} |
||||
|
||||
partial void OnConstruction(); |
||||
|
||||
public EmptyMessage(EmptyMessage other) : this() { |
||||
} |
||||
|
||||
public EmptyMessage Clone() { |
||||
return new EmptyMessage(this); |
||||
} |
||||
|
||||
public override bool Equals(object other) { |
||||
return Equals(other as EmptyMessage); |
||||
} |
||||
|
||||
public bool Equals(EmptyMessage other) { |
||||
if (ReferenceEquals(other, null)) { |
||||
return false; |
||||
} |
||||
if (ReferenceEquals(other, this)) { |
||||
return true; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
public override int GetHashCode() { |
||||
int hash = 1; |
||||
return hash; |
||||
} |
||||
|
||||
public override string ToString() { |
||||
return pb::JsonFormatter.ToDiagnosticString(this); |
||||
} |
||||
|
||||
public void WriteTo(pb::CodedOutputStream output) { |
||||
} |
||||
|
||||
public int CalculateSize() { |
||||
int size = 0; |
||||
return size; |
||||
} |
||||
|
||||
public void MergeFrom(EmptyMessage other) { |
||||
if (other == null) { |
||||
return; |
||||
} |
||||
} |
||||
|
||||
public void MergeFrom(pb::CodedInputStream input) { |
||||
uint tag; |
||||
while ((tag = input.ReadTag()) != 0) { |
||||
switch(tag) { |
||||
default: |
||||
input.SkipLastField(); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
#endregion |
||||
|
||||
} |
||||
|
||||
#endregion Designer generated code |
@ -0,0 +1,152 @@ |
||||
// Generated by the protocol buffer compiler. DO NOT EDIT! |
||||
// source: src/proto/grpc/testing/metrics.proto |
||||
#region Designer generated code |
||||
|
||||
using System; |
||||
using System.Threading; |
||||
using System.Threading.Tasks; |
||||
using Grpc.Core; |
||||
|
||||
namespace Grpc.Testing { |
||||
public static class MetricsService |
||||
{ |
||||
static readonly string __ServiceName = "grpc.testing.MetricsService"; |
||||
|
||||
static readonly Marshaller<global::Grpc.Testing.EmptyMessage> __Marshaller_EmptyMessage = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.EmptyMessage.Parser.ParseFrom); |
||||
static readonly Marshaller<global::Grpc.Testing.GaugeResponse> __Marshaller_GaugeResponse = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeResponse.Parser.ParseFrom); |
||||
static readonly Marshaller<global::Grpc.Testing.GaugeRequest> __Marshaller_GaugeRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.GaugeRequest.Parser.ParseFrom); |
||||
|
||||
static readonly Method<global::Grpc.Testing.EmptyMessage, global::Grpc.Testing.GaugeResponse> __Method_GetAllGauges = new Method<global::Grpc.Testing.EmptyMessage, global::Grpc.Testing.GaugeResponse>( |
||||
MethodType.ServerStreaming, |
||||
__ServiceName, |
||||
"GetAllGauges", |
||||
__Marshaller_EmptyMessage, |
||||
__Marshaller_GaugeResponse); |
||||
|
||||
static readonly Method<global::Grpc.Testing.GaugeRequest, global::Grpc.Testing.GaugeResponse> __Method_GetGauge = new Method<global::Grpc.Testing.GaugeRequest, global::Grpc.Testing.GaugeResponse>( |
||||
MethodType.Unary, |
||||
__ServiceName, |
||||
"GetGauge", |
||||
__Marshaller_GaugeRequest, |
||||
__Marshaller_GaugeResponse); |
||||
|
||||
// service descriptor |
||||
public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor |
||||
{ |
||||
get { return global::Grpc.Testing.MetricsReflection.Descriptor.Services[0]; } |
||||
} |
||||
|
||||
// client interface |
||||
[System.Obsolete("Client side interfaced will be removed in the next release. Use client class directly.")] |
||||
public interface IMetricsServiceClient |
||||
{ |
||||
AsyncServerStreamingCall<global::Grpc.Testing.GaugeResponse> GetAllGauges(global::Grpc.Testing.EmptyMessage request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); |
||||
AsyncServerStreamingCall<global::Grpc.Testing.GaugeResponse> GetAllGauges(global::Grpc.Testing.EmptyMessage request, CallOptions options); |
||||
global::Grpc.Testing.GaugeResponse GetGauge(global::Grpc.Testing.GaugeRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); |
||||
global::Grpc.Testing.GaugeResponse GetGauge(global::Grpc.Testing.GaugeRequest request, CallOptions options); |
||||
AsyncUnaryCall<global::Grpc.Testing.GaugeResponse> GetGaugeAsync(global::Grpc.Testing.GaugeRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)); |
||||
AsyncUnaryCall<global::Grpc.Testing.GaugeResponse> GetGaugeAsync(global::Grpc.Testing.GaugeRequest request, CallOptions options); |
||||
} |
||||
|
||||
// server-side interface |
||||
[System.Obsolete("Service implementations should inherit from the generated abstract base class instead.")] |
||||
public interface IMetricsService |
||||
{ |
||||
Task GetAllGauges(global::Grpc.Testing.EmptyMessage request, IServerStreamWriter<global::Grpc.Testing.GaugeResponse> responseStream, ServerCallContext context); |
||||
Task<global::Grpc.Testing.GaugeResponse> GetGauge(global::Grpc.Testing.GaugeRequest request, ServerCallContext context); |
||||
} |
||||
|
||||
// server-side abstract class |
||||
public abstract class MetricsServiceBase |
||||
{ |
||||
public virtual Task GetAllGauges(global::Grpc.Testing.EmptyMessage request, IServerStreamWriter<global::Grpc.Testing.GaugeResponse> responseStream, ServerCallContext context) |
||||
{ |
||||
throw new RpcException(new Status(StatusCode.Unimplemented, "")); |
||||
} |
||||
|
||||
public virtual Task<global::Grpc.Testing.GaugeResponse> GetGauge(global::Grpc.Testing.GaugeRequest request, ServerCallContext context) |
||||
{ |
||||
throw new RpcException(new Status(StatusCode.Unimplemented, "")); |
||||
} |
||||
|
||||
} |
||||
|
||||
// client stub |
||||
#pragma warning disable 0618 |
||||
public class MetricsServiceClient : ClientBase<MetricsServiceClient>, IMetricsServiceClient |
||||
#pragma warning restore 0618 |
||||
{ |
||||
public MetricsServiceClient(Channel channel) : base(channel) |
||||
{ |
||||
} |
||||
public MetricsServiceClient(CallInvoker callInvoker) : base(callInvoker) |
||||
{ |
||||
} |
||||
///<summary>Protected parameterless constructor to allow creation of test doubles.</summary> |
||||
protected MetricsServiceClient() : base() |
||||
{ |
||||
} |
||||
///<summary>Protected constructor to allow creation of configured clients.</summary> |
||||
protected MetricsServiceClient(ClientBaseConfiguration configuration) : base(configuration) |
||||
{ |
||||
} |
||||
|
||||
public virtual AsyncServerStreamingCall<global::Grpc.Testing.GaugeResponse> GetAllGauges(global::Grpc.Testing.EmptyMessage request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) |
||||
{ |
||||
return GetAllGauges(request, new CallOptions(headers, deadline, cancellationToken)); |
||||
} |
||||
public virtual AsyncServerStreamingCall<global::Grpc.Testing.GaugeResponse> GetAllGauges(global::Grpc.Testing.EmptyMessage request, CallOptions options) |
||||
{ |
||||
return CallInvoker.AsyncServerStreamingCall(__Method_GetAllGauges, null, options, request); |
||||
} |
||||
public virtual global::Grpc.Testing.GaugeResponse GetGauge(global::Grpc.Testing.GaugeRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) |
||||
{ |
||||
return GetGauge(request, new CallOptions(headers, deadline, cancellationToken)); |
||||
} |
||||
public virtual global::Grpc.Testing.GaugeResponse GetGauge(global::Grpc.Testing.GaugeRequest request, CallOptions options) |
||||
{ |
||||
return CallInvoker.BlockingUnaryCall(__Method_GetGauge, null, options, request); |
||||
} |
||||
public virtual AsyncUnaryCall<global::Grpc.Testing.GaugeResponse> GetGaugeAsync(global::Grpc.Testing.GaugeRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) |
||||
{ |
||||
return GetGaugeAsync(request, new CallOptions(headers, deadline, cancellationToken)); |
||||
} |
||||
public virtual AsyncUnaryCall<global::Grpc.Testing.GaugeResponse> GetGaugeAsync(global::Grpc.Testing.GaugeRequest request, CallOptions options) |
||||
{ |
||||
return CallInvoker.AsyncUnaryCall(__Method_GetGauge, null, options, request); |
||||
} |
||||
protected override MetricsServiceClient NewInstance(ClientBaseConfiguration configuration) |
||||
{ |
||||
return new MetricsServiceClient(configuration); |
||||
} |
||||
} |
||||
|
||||
// creates a new client |
||||
public static MetricsServiceClient NewClient(Channel channel) |
||||
{ |
||||
return new MetricsServiceClient(channel); |
||||
} |
||||
|
||||
// creates service definition that can be registered with a server |
||||
#pragma warning disable 0618 |
||||
public static ServerServiceDefinition BindService(IMetricsService serviceImpl) |
||||
#pragma warning restore 0618 |
||||
{ |
||||
return ServerServiceDefinition.CreateBuilder(__ServiceName) |
||||
.AddMethod(__Method_GetAllGauges, serviceImpl.GetAllGauges) |
||||
.AddMethod(__Method_GetGauge, serviceImpl.GetGauge).Build(); |
||||
} |
||||
|
||||
// creates service definition that can be registered with a server |
||||
#pragma warning disable 0618 |
||||
public static ServerServiceDefinition BindService(MetricsServiceBase serviceImpl) |
||||
#pragma warning restore 0618 |
||||
{ |
||||
return ServerServiceDefinition.CreateBuilder(__ServiceName) |
||||
.AddMethod(__Method_GetAllGauges, serviceImpl.GetAllGauges) |
||||
.AddMethod(__Method_GetGauge, serviceImpl.GetGauge).Build(); |
||||
} |
||||
|
||||
} |
||||
} |
||||
#endregion |
@ -0,0 +1,318 @@ |
||||
#region Copyright notice and license |
||||
|
||||
// Copyright 2015-2016, 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.Diagnostics; |
||||
using System.Linq; |
||||
using System.Threading; |
||||
using System.Threading.Tasks; |
||||
|
||||
using CommandLine; |
||||
using CommandLine.Text; |
||||
using Grpc.Core; |
||||
using Grpc.Core.Logging; |
||||
using Grpc.Core.Utils; |
||||
using Grpc.Testing; |
||||
|
||||
namespace Grpc.IntegrationTesting |
||||
{ |
||||
public class StressTestClient |
||||
{ |
||||
static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<StressTestClient>(); |
||||
const double SecondsToNanos = 1e9; |
||||
|
||||
private class ClientOptions |
||||
{ |
||||
[Option("server_addresses", DefaultValue = "localhost:8080")] |
||||
public string ServerAddresses { get; set; } |
||||
|
||||
[Option("test_cases", DefaultValue = "large_unary:100")] |
||||
public string TestCases { get; set; } |
||||
|
||||
[Option("test_duration_secs", DefaultValue = -1)] |
||||
public int TestDurationSecs { get; set; } |
||||
|
||||
[Option("num_channels_per_server", DefaultValue = 1)] |
||||
public int NumChannelsPerServer { get; set; } |
||||
|
||||
[Option("num_stubs_per_channel", DefaultValue = 1)] |
||||
public int NumStubsPerChannel { get; set; } |
||||
|
||||
[Option("metrics_port", DefaultValue = 8081)] |
||||
public int MetricsPort { get; set; } |
||||
|
||||
[HelpOption] |
||||
public string GetUsage() |
||||
{ |
||||
var help = new HelpText |
||||
{ |
||||
Heading = "gRPC C# stress test client", |
||||
AddDashesToOption = true |
||||
}; |
||||
help.AddPreOptionsLine("Usage:"); |
||||
help.AddOptions(this); |
||||
return help; |
||||
} |
||||
} |
||||
|
||||
ClientOptions options; |
||||
List<string> serverAddresses; |
||||
Dictionary<string, int> weightedTestCases; |
||||
WeightedRandomGenerator testCaseGenerator; |
||||
|
||||
// cancellation will be emitted once test_duration_secs has elapsed. |
||||
CancellationTokenSource finishedTokenSource = new CancellationTokenSource(); |
||||
Histogram histogram = new Histogram(0.01, 60 * SecondsToNanos); |
||||
|
||||
private StressTestClient(ClientOptions options, List<string> serverAddresses, Dictionary<string, int> weightedTestCases) |
||||
{ |
||||
this.options = options; |
||||
this.serverAddresses = serverAddresses; |
||||
this.weightedTestCases = weightedTestCases; |
||||
this.testCaseGenerator = new WeightedRandomGenerator(this.weightedTestCases); |
||||
} |
||||
|
||||
public static void Run(string[] args) |
||||
{ |
||||
var options = new ClientOptions(); |
||||
if (!Parser.Default.ParseArguments(args, options)) |
||||
{ |
||||
Environment.Exit(1); |
||||
} |
||||
|
||||
GrpcPreconditions.CheckArgument(options.NumChannelsPerServer > 0); |
||||
GrpcPreconditions.CheckArgument(options.NumStubsPerChannel > 0); |
||||
|
||||
var serverAddresses = options.ServerAddresses.Split(','); |
||||
GrpcPreconditions.CheckArgument(serverAddresses.Length > 0, "You need to provide at least one server address"); |
||||
|
||||
var testCases = ParseWeightedTestCases(options.TestCases); |
||||
GrpcPreconditions.CheckArgument(testCases.Count > 0, "You need to provide at least one test case"); |
||||
|
||||
var interopClient = new StressTestClient(options, serverAddresses.ToList(), testCases); |
||||
interopClient.Run().Wait(); |
||||
} |
||||
|
||||
async Task Run() |
||||
{ |
||||
var metricsServer = new Server() |
||||
{ |
||||
Services = { MetricsService.BindService(new MetricsServiceImpl(histogram)) }, |
||||
Ports = { { "[::]", options.MetricsPort, ServerCredentials.Insecure } } |
||||
}; |
||||
metricsServer.Start(); |
||||
|
||||
if (options.TestDurationSecs >= 0) |
||||
{ |
||||
finishedTokenSource.CancelAfter(TimeSpan.FromSeconds(options.TestDurationSecs)); |
||||
} |
||||
|
||||
var tasks = new List<Task>(); |
||||
var channels = new List<Channel>(); |
||||
foreach (var serverAddress in serverAddresses) |
||||
{ |
||||
for (int i = 0; i < options.NumChannelsPerServer; i++) |
||||
{ |
||||
var channel = new Channel(serverAddress, ChannelCredentials.Insecure); |
||||
channels.Add(channel); |
||||
for (int j = 0; j < options.NumStubsPerChannel; j++) |
||||
{ |
||||
var client = TestService.NewClient(channel); |
||||
var task = Task.Factory.StartNew(() => RunBodyAsync(client).GetAwaiter().GetResult(), |
||||
TaskCreationOptions.LongRunning); |
||||
tasks.Add(task); |
||||
} |
||||
} |
||||
} |
||||
await Task.WhenAll(tasks); |
||||
|
||||
foreach (var channel in channels) |
||||
{ |
||||
await channel.ShutdownAsync(); |
||||
} |
||||
|
||||
await metricsServer.ShutdownAsync(); |
||||
} |
||||
|
||||
async Task RunBodyAsync(TestService.TestServiceClient client) |
||||
{ |
||||
Logger.Info("Starting stress test client thread."); |
||||
while (!finishedTokenSource.Token.IsCancellationRequested) |
||||
{ |
||||
var testCase = testCaseGenerator.GetNext(); |
||||
|
||||
var stopwatch = Stopwatch.StartNew(); |
||||
|
||||
await RunTestCaseAsync(client, testCase); |
||||
|
||||
stopwatch.Stop(); |
||||
histogram.AddObservation(stopwatch.Elapsed.TotalSeconds * SecondsToNanos); |
||||
} |
||||
Logger.Info("Stress test client thread finished."); |
||||
} |
||||
|
||||
async Task RunTestCaseAsync(TestService.TestServiceClient client, string testCase) |
||||
{ |
||||
switch (testCase) |
||||
{ |
||||
case "empty_unary": |
||||
InteropClient.RunEmptyUnary(client); |
||||
break; |
||||
case "large_unary": |
||||
InteropClient.RunLargeUnary(client); |
||||
break; |
||||
case "client_streaming": |
||||
await InteropClient.RunClientStreamingAsync(client); |
||||
break; |
||||
case "server_streaming": |
||||
await InteropClient.RunServerStreamingAsync(client); |
||||
break; |
||||
case "ping_pong": |
||||
await InteropClient.RunPingPongAsync(client); |
||||
break; |
||||
case "empty_stream": |
||||
await InteropClient.RunEmptyStreamAsync(client); |
||||
break; |
||||
case "cancel_after_begin": |
||||
await InteropClient.RunCancelAfterBeginAsync(client); |
||||
break; |
||||
case "cancel_after_first_response": |
||||
await InteropClient.RunCancelAfterFirstResponseAsync(client); |
||||
break; |
||||
case "timeout_on_sleeping_server": |
||||
await InteropClient.RunTimeoutOnSleepingServerAsync(client); |
||||
break; |
||||
case "custom_metadata": |
||||
await InteropClient.RunCustomMetadataAsync(client); |
||||
break; |
||||
case "status_code_and_message": |
||||
await InteropClient.RunStatusCodeAndMessageAsync(client); |
||||
break; |
||||
default: |
||||
throw new ArgumentException("Unsupported test case " + testCase); |
||||
} |
||||
} |
||||
|
||||
static Dictionary<string, int> ParseWeightedTestCases(string weightedTestCases) |
||||
{ |
||||
var result = new Dictionary<string, int>(); |
||||
foreach (var weightedTestCase in weightedTestCases.Split(',')) |
||||
{ |
||||
var parts = weightedTestCase.Split(new char[] {':'}, 2); |
||||
GrpcPreconditions.CheckArgument(parts.Length == 2, "Malformed test_cases option."); |
||||
result.Add(parts[0], int.Parse(parts[1])); |
||||
} |
||||
return result; |
||||
} |
||||
|
||||
class WeightedRandomGenerator |
||||
{ |
||||
readonly Random random = new Random(); |
||||
readonly List<Tuple<int, string>> cumulativeSums; |
||||
readonly int weightSum; |
||||
|
||||
public WeightedRandomGenerator(Dictionary<string, int> weightedItems) |
||||
{ |
||||
cumulativeSums = new List<Tuple<int, string>>(); |
||||
weightSum = 0; |
||||
foreach (var entry in weightedItems) |
||||
{ |
||||
weightSum += entry.Value; |
||||
cumulativeSums.Add(Tuple.Create(weightSum, entry.Key)); |
||||
} |
||||
} |
||||
|
||||
public string GetNext() |
||||
{ |
||||
int rand = random.Next(weightSum); |
||||
foreach (var entry in cumulativeSums) |
||||
{ |
||||
if (rand < entry.Item1) |
||||
{ |
||||
return entry.Item2; |
||||
} |
||||
} |
||||
throw new InvalidOperationException("GetNext() failed."); |
||||
} |
||||
} |
||||
|
||||
class MetricsServiceImpl : MetricsService.MetricsServiceBase |
||||
{ |
||||
const string GaugeName = "csharp_overall_qps"; |
||||
|
||||
readonly Histogram histogram; |
||||
readonly WallClockStopwatch wallClockStopwatch = new WallClockStopwatch(); |
||||
|
||||
public MetricsServiceImpl(Histogram histogram) |
||||
{ |
||||
this.histogram = histogram; |
||||
} |
||||
|
||||
public override Task<GaugeResponse> GetGauge(GaugeRequest request, ServerCallContext context) |
||||
{ |
||||
if (request.Name == GaugeName) |
||||
{ |
||||
long qps = GetQpsAndReset(); |
||||
|
||||
return Task.FromResult(new GaugeResponse |
||||
{ |
||||
Name = GaugeName, |
||||
LongValue = qps |
||||
}); |
||||
} |
||||
throw new RpcException(new Status(StatusCode.InvalidArgument, "Gauge does not exist")); |
||||
} |
||||
|
||||
public override async Task GetAllGauges(EmptyMessage request, IServerStreamWriter<GaugeResponse> responseStream, ServerCallContext context) |
||||
{ |
||||
long qps = GetQpsAndReset(); |
||||
|
||||
var response = new GaugeResponse |
||||
{ |
||||
Name = GaugeName, |
||||
LongValue = qps |
||||
}; |
||||
await responseStream.WriteAsync(response); |
||||
} |
||||
|
||||
long GetQpsAndReset() |
||||
{ |
||||
var snapshot = histogram.GetSnapshot(true); |
||||
var elapsedSnapshot = wallClockStopwatch.GetElapsedSnapshot(true); |
||||
|
||||
return (long) (snapshot.Count / elapsedSnapshot.Seconds); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,2 +0,0 @@ |
||||
build |
||||
node_modules |
@ -0,0 +1 @@ |
||||
**/*_pb.js |
@ -1,28 +0,0 @@ |
||||
{ |
||||
"bitwise": true, |
||||
"curly": true, |
||||
"eqeqeq": true, |
||||
"esnext": true, |
||||
"freeze": true, |
||||
"immed": true, |
||||
"indent": 2, |
||||
"latedef": "nofunc", |
||||
"maxlen": 80, |
||||
"newcap": true, |
||||
"node": true, |
||||
"noarg": true, |
||||
"quotmark": "single", |
||||
"strict": true, |
||||
"trailing": true, |
||||
"undef": true, |
||||
"unused": "vars", |
||||
"globals": { |
||||
/* Mocha-provided globals */ |
||||
"describe": false, |
||||
"it": false, |
||||
"before": false, |
||||
"beforeEach": false, |
||||
"after": false, |
||||
"afterEach": false |
||||
} |
||||
} |
@ -0,0 +1,99 @@ |
||||
// GENERATED CODE -- DO NOT EDIT!
|
||||
|
||||
'use strict'; |
||||
var grpc = require('grpc'); |
||||
var math_pb = require('./math_pb.js'); |
||||
|
||||
function serialize_DivArgs(arg) { |
||||
if (!(arg instanceof math_pb.DivArgs)) { |
||||
throw new Error('Expected argument of type DivArgs'); |
||||
} |
||||
return new Buffer(arg.serializeBinary()); |
||||
} |
||||
|
||||
function deserialize_DivArgs(buffer_arg) { |
||||
return math_pb.DivArgs.deserializeBinary(new Uint8Array(buffer_arg)); |
||||
} |
||||
|
||||
function serialize_DivReply(arg) { |
||||
if (!(arg instanceof math_pb.DivReply)) { |
||||
throw new Error('Expected argument of type DivReply'); |
||||
} |
||||
return new Buffer(arg.serializeBinary()); |
||||
} |
||||
|
||||
function deserialize_DivReply(buffer_arg) { |
||||
return math_pb.DivReply.deserializeBinary(new Uint8Array(buffer_arg)); |
||||
} |
||||
|
||||
function serialize_FibArgs(arg) { |
||||
if (!(arg instanceof math_pb.FibArgs)) { |
||||
throw new Error('Expected argument of type FibArgs'); |
||||
} |
||||
return new Buffer(arg.serializeBinary()); |
||||
} |
||||
|
||||
function deserialize_FibArgs(buffer_arg) { |
||||
return math_pb.FibArgs.deserializeBinary(new Uint8Array(buffer_arg)); |
||||
} |
||||
|
||||
function serialize_Num(arg) { |
||||
if (!(arg instanceof math_pb.Num)) { |
||||
throw new Error('Expected argument of type Num'); |
||||
} |
||||
return new Buffer(arg.serializeBinary()); |
||||
} |
||||
|
||||
function deserialize_Num(buffer_arg) { |
||||
return math_pb.Num.deserializeBinary(new Uint8Array(buffer_arg)); |
||||
} |
||||
|
||||
|
||||
var MathService = exports.MathService = { |
||||
div: { |
||||
path: '/math.Math/Div', |
||||
requestStream: false, |
||||
responseStream: false, |
||||
requestType: math_pb.DivArgs, |
||||
responseType: math_pb.DivReply, |
||||
requestSerialize: serialize_DivArgs, |
||||
requestDeserialize: deserialize_DivArgs, |
||||
responseSerialize: serialize_DivReply, |
||||
responseDeserialize: deserialize_DivReply, |
||||
}, |
||||
divMany: { |
||||
path: '/math.Math/DivMany', |
||||
requestStream: true, |
||||
responseStream: true, |
||||
requestType: math_pb.DivArgs, |
||||
responseType: math_pb.DivReply, |
||||
requestSerialize: serialize_DivArgs, |
||||
requestDeserialize: deserialize_DivArgs, |
||||
responseSerialize: serialize_DivReply, |
||||
responseDeserialize: deserialize_DivReply, |
||||
}, |
||||
fib: { |
||||
path: '/math.Math/Fib', |
||||
requestStream: false, |
||||
responseStream: true, |
||||
requestType: math_pb.FibArgs, |
||||
responseType: math_pb.Num, |
||||
requestSerialize: serialize_FibArgs, |
||||
requestDeserialize: deserialize_FibArgs, |
||||
responseSerialize: serialize_Num, |
||||
responseDeserialize: deserialize_Num, |
||||
}, |
||||
sum: { |
||||
path: '/math.Math/Sum', |
||||
requestStream: true, |
||||
responseStream: false, |
||||
requestType: math_pb.Num, |
||||
responseType: math_pb.Num, |
||||
requestSerialize: serialize_Num, |
||||
requestDeserialize: deserialize_Num, |
||||
responseSerialize: serialize_Num, |
||||
responseDeserialize: deserialize_Num, |
||||
}, |
||||
}; |
||||
|
||||
exports.MathClient = grpc.makeGenericClientConstructor(MathService); |
@ -0,0 +1,866 @@ |
||||
/** |
||||
* @fileoverview |
||||
* @enhanceable |
||||
* @public |
||||
*/ |
||||
// GENERATED CODE -- DO NOT EDIT!
|
||||
|
||||
var jspb = require('google-protobuf'); |
||||
var goog = jspb; |
||||
var global = Function('return this')(); |
||||
|
||||
goog.exportSymbol('proto.math.DivArgs', null, global); |
||||
goog.exportSymbol('proto.math.DivReply', null, global); |
||||
goog.exportSymbol('proto.math.FibArgs', null, global); |
||||
goog.exportSymbol('proto.math.FibReply', null, global); |
||||
goog.exportSymbol('proto.math.Num', null, global); |
||||
|
||||
/** |
||||
* Generated by JsPbCodeGenerator. |
||||
* @param {Array=} opt_data Optional initial data array, typically from a |
||||
* server response, or constructed directly in Javascript. The array is used |
||||
* in place and becomes part of the constructed object. It is not cloned. |
||||
* If no data is provided, the constructed object will be empty, but still |
||||
* valid. |
||||
* @extends {jspb.Message} |
||||
* @constructor |
||||
*/ |
||||
proto.math.DivArgs = function(opt_data) { |
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null); |
||||
}; |
||||
goog.inherits(proto.math.DivArgs, jspb.Message); |
||||
if (goog.DEBUG && !COMPILED) { |
||||
proto.math.DivArgs.displayName = 'proto.math.DivArgs'; |
||||
} |
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) { |
||||
/** |
||||
* Creates an object representation of this proto suitable for use in Soy templates. |
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name. |
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. |
||||
* For the list of reserved names please see: |
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. |
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance |
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object} |
||||
*/ |
||||
proto.math.DivArgs.prototype.toObject = function(opt_includeInstance) { |
||||
return proto.math.DivArgs.toObject(opt_includeInstance, this); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Static version of the {@see toObject} method. |
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB |
||||
* instance for transitional soy proto support: |
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.math.DivArgs} msg The msg instance to transform. |
||||
* @return {!Object} |
||||
*/ |
||||
proto.math.DivArgs.toObject = function(includeInstance, msg) { |
||||
var f, obj = { |
||||
dividend: msg.getDividend(), |
||||
divisor: msg.getDivisor() |
||||
}; |
||||
|
||||
if (includeInstance) { |
||||
obj.$jspbMessageInstance = msg |
||||
} |
||||
return obj; |
||||
}; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format). |
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize. |
||||
* @return {!proto.math.DivArgs} |
||||
*/ |
||||
proto.math.DivArgs.deserializeBinary = function(bytes) { |
||||
var reader = new jspb.BinaryReader(bytes); |
||||
var msg = new proto.math.DivArgs; |
||||
return proto.math.DivArgs.deserializeBinaryFromReader(msg, reader); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format) from the |
||||
* given reader into the given message object. |
||||
* @param {!proto.math.DivArgs} msg The message object to deserialize into. |
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use. |
||||
* @return {!proto.math.DivArgs} |
||||
*/ |
||||
proto.math.DivArgs.deserializeBinaryFromReader = function(msg, reader) { |
||||
while (reader.nextField()) { |
||||
if (reader.isEndGroup()) { |
||||
break; |
||||
} |
||||
var field = reader.getFieldNumber(); |
||||
switch (field) { |
||||
case 1: |
||||
var value = /** @type {number} */ (reader.readInt64()); |
||||
msg.setDividend(value); |
||||
break; |
||||
case 2: |
||||
var value = /** @type {number} */ (reader.readInt64()); |
||||
msg.setDivisor(value); |
||||
break; |
||||
default: |
||||
reader.skipField(); |
||||
break; |
||||
} |
||||
} |
||||
return msg; |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Class method variant: serializes the given message to binary data |
||||
* (in protobuf wire format), writing to the given BinaryWriter. |
||||
* @param {!proto.math.DivArgs} message |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.math.DivArgs.serializeBinaryToWriter = function(message, writer) { |
||||
message.serializeBinaryToWriter(writer); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format). |
||||
* @return {!Uint8Array} |
||||
*/ |
||||
proto.math.DivArgs.prototype.serializeBinary = function() { |
||||
var writer = new jspb.BinaryWriter(); |
||||
this.serializeBinaryToWriter(writer); |
||||
return writer.getResultBuffer(); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format), |
||||
* writing to the given BinaryWriter. |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.math.DivArgs.prototype.serializeBinaryToWriter = function (writer) { |
||||
var f = undefined; |
||||
f = this.getDividend(); |
||||
if (f !== 0) { |
||||
writer.writeInt64( |
||||
1, |
||||
f |
||||
); |
||||
} |
||||
f = this.getDivisor(); |
||||
if (f !== 0) { |
||||
writer.writeInt64( |
||||
2, |
||||
f |
||||
); |
||||
} |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Creates a deep clone of this proto. No data is shared with the original. |
||||
* @return {!proto.math.DivArgs} The clone. |
||||
*/ |
||||
proto.math.DivArgs.prototype.cloneMessage = function() { |
||||
return /** @type {!proto.math.DivArgs} */ (jspb.Message.cloneMessage(this)); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* optional int64 dividend = 1; |
||||
* @return {number} |
||||
*/ |
||||
proto.math.DivArgs.prototype.getDividend = function() { |
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0)); |
||||
}; |
||||
|
||||
|
||||
/** @param {number} value */ |
||||
proto.math.DivArgs.prototype.setDividend = function(value) { |
||||
jspb.Message.setField(this, 1, value); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* optional int64 divisor = 2; |
||||
* @return {number} |
||||
*/ |
||||
proto.math.DivArgs.prototype.getDivisor = function() { |
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 2, 0)); |
||||
}; |
||||
|
||||
|
||||
/** @param {number} value */ |
||||
proto.math.DivArgs.prototype.setDivisor = function(value) { |
||||
jspb.Message.setField(this, 2, value); |
||||
}; |
||||
|
||||
|
||||
|
||||
/** |
||||
* Generated by JsPbCodeGenerator. |
||||
* @param {Array=} opt_data Optional initial data array, typically from a |
||||
* server response, or constructed directly in Javascript. The array is used |
||||
* in place and becomes part of the constructed object. It is not cloned. |
||||
* If no data is provided, the constructed object will be empty, but still |
||||
* valid. |
||||
* @extends {jspb.Message} |
||||
* @constructor |
||||
*/ |
||||
proto.math.DivReply = function(opt_data) { |
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null); |
||||
}; |
||||
goog.inherits(proto.math.DivReply, jspb.Message); |
||||
if (goog.DEBUG && !COMPILED) { |
||||
proto.math.DivReply.displayName = 'proto.math.DivReply'; |
||||
} |
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) { |
||||
/** |
||||
* Creates an object representation of this proto suitable for use in Soy templates. |
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name. |
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. |
||||
* For the list of reserved names please see: |
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. |
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance |
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object} |
||||
*/ |
||||
proto.math.DivReply.prototype.toObject = function(opt_includeInstance) { |
||||
return proto.math.DivReply.toObject(opt_includeInstance, this); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Static version of the {@see toObject} method. |
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB |
||||
* instance for transitional soy proto support: |
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.math.DivReply} msg The msg instance to transform. |
||||
* @return {!Object} |
||||
*/ |
||||
proto.math.DivReply.toObject = function(includeInstance, msg) { |
||||
var f, obj = { |
||||
quotient: msg.getQuotient(), |
||||
remainder: msg.getRemainder() |
||||
}; |
||||
|
||||
if (includeInstance) { |
||||
obj.$jspbMessageInstance = msg |
||||
} |
||||
return obj; |
||||
}; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format). |
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize. |
||||
* @return {!proto.math.DivReply} |
||||
*/ |
||||
proto.math.DivReply.deserializeBinary = function(bytes) { |
||||
var reader = new jspb.BinaryReader(bytes); |
||||
var msg = new proto.math.DivReply; |
||||
return proto.math.DivReply.deserializeBinaryFromReader(msg, reader); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format) from the |
||||
* given reader into the given message object. |
||||
* @param {!proto.math.DivReply} msg The message object to deserialize into. |
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use. |
||||
* @return {!proto.math.DivReply} |
||||
*/ |
||||
proto.math.DivReply.deserializeBinaryFromReader = function(msg, reader) { |
||||
while (reader.nextField()) { |
||||
if (reader.isEndGroup()) { |
||||
break; |
||||
} |
||||
var field = reader.getFieldNumber(); |
||||
switch (field) { |
||||
case 1: |
||||
var value = /** @type {number} */ (reader.readInt64()); |
||||
msg.setQuotient(value); |
||||
break; |
||||
case 2: |
||||
var value = /** @type {number} */ (reader.readInt64()); |
||||
msg.setRemainder(value); |
||||
break; |
||||
default: |
||||
reader.skipField(); |
||||
break; |
||||
} |
||||
} |
||||
return msg; |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Class method variant: serializes the given message to binary data |
||||
* (in protobuf wire format), writing to the given BinaryWriter. |
||||
* @param {!proto.math.DivReply} message |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.math.DivReply.serializeBinaryToWriter = function(message, writer) { |
||||
message.serializeBinaryToWriter(writer); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format). |
||||
* @return {!Uint8Array} |
||||
*/ |
||||
proto.math.DivReply.prototype.serializeBinary = function() { |
||||
var writer = new jspb.BinaryWriter(); |
||||
this.serializeBinaryToWriter(writer); |
||||
return writer.getResultBuffer(); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format), |
||||
* writing to the given BinaryWriter. |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.math.DivReply.prototype.serializeBinaryToWriter = function (writer) { |
||||
var f = undefined; |
||||
f = this.getQuotient(); |
||||
if (f !== 0) { |
||||
writer.writeInt64( |
||||
1, |
||||
f |
||||
); |
||||
} |
||||
f = this.getRemainder(); |
||||
if (f !== 0) { |
||||
writer.writeInt64( |
||||
2, |
||||
f |
||||
); |
||||
} |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Creates a deep clone of this proto. No data is shared with the original. |
||||
* @return {!proto.math.DivReply} The clone. |
||||
*/ |
||||
proto.math.DivReply.prototype.cloneMessage = function() { |
||||
return /** @type {!proto.math.DivReply} */ (jspb.Message.cloneMessage(this)); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* optional int64 quotient = 1; |
||||
* @return {number} |
||||
*/ |
||||
proto.math.DivReply.prototype.getQuotient = function() { |
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0)); |
||||
}; |
||||
|
||||
|
||||
/** @param {number} value */ |
||||
proto.math.DivReply.prototype.setQuotient = function(value) { |
||||
jspb.Message.setField(this, 1, value); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* optional int64 remainder = 2; |
||||
* @return {number} |
||||
*/ |
||||
proto.math.DivReply.prototype.getRemainder = function() { |
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 2, 0)); |
||||
}; |
||||
|
||||
|
||||
/** @param {number} value */ |
||||
proto.math.DivReply.prototype.setRemainder = function(value) { |
||||
jspb.Message.setField(this, 2, value); |
||||
}; |
||||
|
||||
|
||||
|
||||
/** |
||||
* Generated by JsPbCodeGenerator. |
||||
* @param {Array=} opt_data Optional initial data array, typically from a |
||||
* server response, or constructed directly in Javascript. The array is used |
||||
* in place and becomes part of the constructed object. It is not cloned. |
||||
* If no data is provided, the constructed object will be empty, but still |
||||
* valid. |
||||
* @extends {jspb.Message} |
||||
* @constructor |
||||
*/ |
||||
proto.math.FibArgs = function(opt_data) { |
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null); |
||||
}; |
||||
goog.inherits(proto.math.FibArgs, jspb.Message); |
||||
if (goog.DEBUG && !COMPILED) { |
||||
proto.math.FibArgs.displayName = 'proto.math.FibArgs'; |
||||
} |
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) { |
||||
/** |
||||
* Creates an object representation of this proto suitable for use in Soy templates. |
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name. |
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. |
||||
* For the list of reserved names please see: |
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. |
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance |
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object} |
||||
*/ |
||||
proto.math.FibArgs.prototype.toObject = function(opt_includeInstance) { |
||||
return proto.math.FibArgs.toObject(opt_includeInstance, this); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Static version of the {@see toObject} method. |
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB |
||||
* instance for transitional soy proto support: |
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.math.FibArgs} msg The msg instance to transform. |
||||
* @return {!Object} |
||||
*/ |
||||
proto.math.FibArgs.toObject = function(includeInstance, msg) { |
||||
var f, obj = { |
||||
limit: msg.getLimit() |
||||
}; |
||||
|
||||
if (includeInstance) { |
||||
obj.$jspbMessageInstance = msg |
||||
} |
||||
return obj; |
||||
}; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format). |
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize. |
||||
* @return {!proto.math.FibArgs} |
||||
*/ |
||||
proto.math.FibArgs.deserializeBinary = function(bytes) { |
||||
var reader = new jspb.BinaryReader(bytes); |
||||
var msg = new proto.math.FibArgs; |
||||
return proto.math.FibArgs.deserializeBinaryFromReader(msg, reader); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format) from the |
||||
* given reader into the given message object. |
||||
* @param {!proto.math.FibArgs} msg The message object to deserialize into. |
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use. |
||||
* @return {!proto.math.FibArgs} |
||||
*/ |
||||
proto.math.FibArgs.deserializeBinaryFromReader = function(msg, reader) { |
||||
while (reader.nextField()) { |
||||
if (reader.isEndGroup()) { |
||||
break; |
||||
} |
||||
var field = reader.getFieldNumber(); |
||||
switch (field) { |
||||
case 1: |
||||
var value = /** @type {number} */ (reader.readInt64()); |
||||
msg.setLimit(value); |
||||
break; |
||||
default: |
||||
reader.skipField(); |
||||
break; |
||||
} |
||||
} |
||||
return msg; |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Class method variant: serializes the given message to binary data |
||||
* (in protobuf wire format), writing to the given BinaryWriter. |
||||
* @param {!proto.math.FibArgs} message |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.math.FibArgs.serializeBinaryToWriter = function(message, writer) { |
||||
message.serializeBinaryToWriter(writer); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format). |
||||
* @return {!Uint8Array} |
||||
*/ |
||||
proto.math.FibArgs.prototype.serializeBinary = function() { |
||||
var writer = new jspb.BinaryWriter(); |
||||
this.serializeBinaryToWriter(writer); |
||||
return writer.getResultBuffer(); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format), |
||||
* writing to the given BinaryWriter. |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.math.FibArgs.prototype.serializeBinaryToWriter = function (writer) { |
||||
var f = undefined; |
||||
f = this.getLimit(); |
||||
if (f !== 0) { |
||||
writer.writeInt64( |
||||
1, |
||||
f |
||||
); |
||||
} |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Creates a deep clone of this proto. No data is shared with the original. |
||||
* @return {!proto.math.FibArgs} The clone. |
||||
*/ |
||||
proto.math.FibArgs.prototype.cloneMessage = function() { |
||||
return /** @type {!proto.math.FibArgs} */ (jspb.Message.cloneMessage(this)); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* optional int64 limit = 1; |
||||
* @return {number} |
||||
*/ |
||||
proto.math.FibArgs.prototype.getLimit = function() { |
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0)); |
||||
}; |
||||
|
||||
|
||||
/** @param {number} value */ |
||||
proto.math.FibArgs.prototype.setLimit = function(value) { |
||||
jspb.Message.setField(this, 1, value); |
||||
}; |
||||
|
||||
|
||||
|
||||
/** |
||||
* Generated by JsPbCodeGenerator. |
||||
* @param {Array=} opt_data Optional initial data array, typically from a |
||||
* server response, or constructed directly in Javascript. The array is used |
||||
* in place and becomes part of the constructed object. It is not cloned. |
||||
* If no data is provided, the constructed object will be empty, but still |
||||
* valid. |
||||
* @extends {jspb.Message} |
||||
* @constructor |
||||
*/ |
||||
proto.math.Num = function(opt_data) { |
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null); |
||||
}; |
||||
goog.inherits(proto.math.Num, jspb.Message); |
||||
if (goog.DEBUG && !COMPILED) { |
||||
proto.math.Num.displayName = 'proto.math.Num'; |
||||
} |
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) { |
||||
/** |
||||
* Creates an object representation of this proto suitable for use in Soy templates. |
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name. |
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. |
||||
* For the list of reserved names please see: |
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. |
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance |
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object} |
||||
*/ |
||||
proto.math.Num.prototype.toObject = function(opt_includeInstance) { |
||||
return proto.math.Num.toObject(opt_includeInstance, this); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Static version of the {@see toObject} method. |
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB |
||||
* instance for transitional soy proto support: |
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.math.Num} msg The msg instance to transform. |
||||
* @return {!Object} |
||||
*/ |
||||
proto.math.Num.toObject = function(includeInstance, msg) { |
||||
var f, obj = { |
||||
num: msg.getNum() |
||||
}; |
||||
|
||||
if (includeInstance) { |
||||
obj.$jspbMessageInstance = msg |
||||
} |
||||
return obj; |
||||
}; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format). |
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize. |
||||
* @return {!proto.math.Num} |
||||
*/ |
||||
proto.math.Num.deserializeBinary = function(bytes) { |
||||
var reader = new jspb.BinaryReader(bytes); |
||||
var msg = new proto.math.Num; |
||||
return proto.math.Num.deserializeBinaryFromReader(msg, reader); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format) from the |
||||
* given reader into the given message object. |
||||
* @param {!proto.math.Num} msg The message object to deserialize into. |
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use. |
||||
* @return {!proto.math.Num} |
||||
*/ |
||||
proto.math.Num.deserializeBinaryFromReader = function(msg, reader) { |
||||
while (reader.nextField()) { |
||||
if (reader.isEndGroup()) { |
||||
break; |
||||
} |
||||
var field = reader.getFieldNumber(); |
||||
switch (field) { |
||||
case 1: |
||||
var value = /** @type {number} */ (reader.readInt64()); |
||||
msg.setNum(value); |
||||
break; |
||||
default: |
||||
reader.skipField(); |
||||
break; |
||||
} |
||||
} |
||||
return msg; |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Class method variant: serializes the given message to binary data |
||||
* (in protobuf wire format), writing to the given BinaryWriter. |
||||
* @param {!proto.math.Num} message |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.math.Num.serializeBinaryToWriter = function(message, writer) { |
||||
message.serializeBinaryToWriter(writer); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format). |
||||
* @return {!Uint8Array} |
||||
*/ |
||||
proto.math.Num.prototype.serializeBinary = function() { |
||||
var writer = new jspb.BinaryWriter(); |
||||
this.serializeBinaryToWriter(writer); |
||||
return writer.getResultBuffer(); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format), |
||||
* writing to the given BinaryWriter. |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.math.Num.prototype.serializeBinaryToWriter = function (writer) { |
||||
var f = undefined; |
||||
f = this.getNum(); |
||||
if (f !== 0) { |
||||
writer.writeInt64( |
||||
1, |
||||
f |
||||
); |
||||
} |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Creates a deep clone of this proto. No data is shared with the original. |
||||
* @return {!proto.math.Num} The clone. |
||||
*/ |
||||
proto.math.Num.prototype.cloneMessage = function() { |
||||
return /** @type {!proto.math.Num} */ (jspb.Message.cloneMessage(this)); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* optional int64 num = 1; |
||||
* @return {number} |
||||
*/ |
||||
proto.math.Num.prototype.getNum = function() { |
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0)); |
||||
}; |
||||
|
||||
|
||||
/** @param {number} value */ |
||||
proto.math.Num.prototype.setNum = function(value) { |
||||
jspb.Message.setField(this, 1, value); |
||||
}; |
||||
|
||||
|
||||
|
||||
/** |
||||
* Generated by JsPbCodeGenerator. |
||||
* @param {Array=} opt_data Optional initial data array, typically from a |
||||
* server response, or constructed directly in Javascript. The array is used |
||||
* in place and becomes part of the constructed object. It is not cloned. |
||||
* If no data is provided, the constructed object will be empty, but still |
||||
* valid. |
||||
* @extends {jspb.Message} |
||||
* @constructor |
||||
*/ |
||||
proto.math.FibReply = function(opt_data) { |
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null); |
||||
}; |
||||
goog.inherits(proto.math.FibReply, jspb.Message); |
||||
if (goog.DEBUG && !COMPILED) { |
||||
proto.math.FibReply.displayName = 'proto.math.FibReply'; |
||||
} |
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) { |
||||
/** |
||||
* Creates an object representation of this proto suitable for use in Soy templates. |
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name. |
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default. |
||||
* For the list of reserved names please see: |
||||
* com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. |
||||
* @param {boolean=} opt_includeInstance Whether to include the JSPB instance |
||||
* for transitional soy proto support: http://goto/soy-param-migration
|
||||
* @return {!Object} |
||||
*/ |
||||
proto.math.FibReply.prototype.toObject = function(opt_includeInstance) { |
||||
return proto.math.FibReply.toObject(opt_includeInstance, this); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Static version of the {@see toObject} method. |
||||
* @param {boolean|undefined} includeInstance Whether to include the JSPB |
||||
* instance for transitional soy proto support: |
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.math.FibReply} msg The msg instance to transform. |
||||
* @return {!Object} |
||||
*/ |
||||
proto.math.FibReply.toObject = function(includeInstance, msg) { |
||||
var f, obj = { |
||||
count: msg.getCount() |
||||
}; |
||||
|
||||
if (includeInstance) { |
||||
obj.$jspbMessageInstance = msg |
||||
} |
||||
return obj; |
||||
}; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format). |
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize. |
||||
* @return {!proto.math.FibReply} |
||||
*/ |
||||
proto.math.FibReply.deserializeBinary = function(bytes) { |
||||
var reader = new jspb.BinaryReader(bytes); |
||||
var msg = new proto.math.FibReply; |
||||
return proto.math.FibReply.deserializeBinaryFromReader(msg, reader); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Deserializes binary data (in protobuf wire format) from the |
||||
* given reader into the given message object. |
||||
* @param {!proto.math.FibReply} msg The message object to deserialize into. |
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use. |
||||
* @return {!proto.math.FibReply} |
||||
*/ |
||||
proto.math.FibReply.deserializeBinaryFromReader = function(msg, reader) { |
||||
while (reader.nextField()) { |
||||
if (reader.isEndGroup()) { |
||||
break; |
||||
} |
||||
var field = reader.getFieldNumber(); |
||||
switch (field) { |
||||
case 1: |
||||
var value = /** @type {number} */ (reader.readInt64()); |
||||
msg.setCount(value); |
||||
break; |
||||
default: |
||||
reader.skipField(); |
||||
break; |
||||
} |
||||
} |
||||
return msg; |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Class method variant: serializes the given message to binary data |
||||
* (in protobuf wire format), writing to the given BinaryWriter. |
||||
* @param {!proto.math.FibReply} message |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.math.FibReply.serializeBinaryToWriter = function(message, writer) { |
||||
message.serializeBinaryToWriter(writer); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format). |
||||
* @return {!Uint8Array} |
||||
*/ |
||||
proto.math.FibReply.prototype.serializeBinary = function() { |
||||
var writer = new jspb.BinaryWriter(); |
||||
this.serializeBinaryToWriter(writer); |
||||
return writer.getResultBuffer(); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Serializes the message to binary data (in protobuf wire format), |
||||
* writing to the given BinaryWriter. |
||||
* @param {!jspb.BinaryWriter} writer |
||||
*/ |
||||
proto.math.FibReply.prototype.serializeBinaryToWriter = function (writer) { |
||||
var f = undefined; |
||||
f = this.getCount(); |
||||
if (f !== 0) { |
||||
writer.writeInt64( |
||||
1, |
||||
f |
||||
); |
||||
} |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* Creates a deep clone of this proto. No data is shared with the original. |
||||
* @return {!proto.math.FibReply} The clone. |
||||
*/ |
||||
proto.math.FibReply.prototype.cloneMessage = function() { |
||||
return /** @type {!proto.math.FibReply} */ (jspb.Message.cloneMessage(this)); |
||||
}; |
||||
|
||||
|
||||
/** |
||||
* optional int64 count = 1; |
||||
* @return {number} |
||||
*/ |
||||
proto.math.FibReply.prototype.getCount = function() { |
||||
return /** @type {number} */ (jspb.Message.getFieldProto3(this, 1, 0)); |
||||
}; |
||||
|
||||
|
||||
/** @param {number} value */ |
||||
proto.math.FibReply.prototype.setCount = function(value) { |
||||
jspb.Message.setField(this, 1, value); |
||||
}; |
||||
|
||||
|
||||
goog.object.extend(exports, proto.math); |
@ -0,0 +1,37 @@ |
||||
/* |
||||
* |
||||
* Copyright 2016, 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. |
||||
* |
||||
*/ |
||||
|
||||
/* This exists solely to allow the generated code to import the grpc module |
||||
* without using a relative path */ |
||||
|
||||
module.exports = require('../../..'); |
@ -0,0 +1,75 @@ |
||||
// Copyright 2016, 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. |
||||
|
||||
// File detached comment 1 |
||||
|
||||
// File detached comment 2 |
||||
|
||||
// File leading comment 1 |
||||
syntax = "proto3"; |
||||
|
||||
// Ignored detached comment |
||||
|
||||
// Ignored package leading comment |
||||
package grpc.testing; |
||||
|
||||
message Request { |
||||
} |
||||
message Response { |
||||
} |
||||
|
||||
// ServiceA detached comment 1 |
||||
|
||||
// ServiceA detached comment 2 |
||||
|
||||
// ServiceA leading comment 1 |
||||
service ServiceA { |
||||
// MethodA1 leading comment 1 |
||||
rpc MethodA1(Request) returns (Response); // MethodA1 trailing comment 1 |
||||
|
||||
// MethodA2 detached leading comment 1 |
||||
|
||||
// Method A2 leading comment 1 |
||||
// Method A2 leading comment 2 |
||||
rpc MethodA2(stream Request) returns (Response); |
||||
// MethodA2 trailing comment 1 |
||||
} |
||||
// Ignored ServiceA trailing comment 1 |
||||
|
||||
// ServiceB leading comment 1 |
||||
service ServiceB { |
||||
// ServiceB trailing comment 1 |
||||
|
||||
// MethodB1 leading comment 1 |
||||
rpc MethodB1(Request) returns (Response); |
||||
// MethodB1 trailing comment 1 |
||||
} |
||||
// Ignored ServiceB trailing comment 2 |
||||
|
||||
// Ignored file trailing comment |
@ -0,0 +1 @@ |
||||
gens/ |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue