Conflicts: src/python/src/__init__.py src/python/src/_adapter/__init__.py src/python/src/_framework/__init__.py src/python/src/_framework/base/__init__.py src/python/src/_framework/base/packets/__init__.py src/python/src/_framework/common/__init__.py src/python/src/_framework/face/__init__.py src/python/src/_framework/face/testing/__init__.py src/python/src/_framework/foundation/__init__.py src/python/src/_junkdrawer/__init__.pypull/654/head
commit
347b83c222
199 changed files with 9843 additions and 6403 deletions
@ -1,173 +0,0 @@ |
|||||||
/*
|
|
||||||
* |
|
||||||
* Copyright 2015, Google Inc. |
|
||||||
* All rights reserved. |
|
||||||
* |
|
||||||
* Redistribution and use in source and binary forms, with or without |
|
||||||
* modification, are permitted provided that the following conditions are |
|
||||||
* met: |
|
||||||
* |
|
||||||
* * Redistributions of source code must retain the above copyright |
|
||||||
* notice, this list of conditions and the following disclaimer. |
|
||||||
* * Redistributions in binary form must reproduce the above |
|
||||||
* copyright notice, this list of conditions and the following disclaimer |
|
||||||
* in the documentation and/or other materials provided with the |
|
||||||
* distribution. |
|
||||||
* * Neither the name of Google Inc. nor the names of its |
|
||||||
* contributors may be used to endorse or promote products derived from |
|
||||||
* this software without specific prior written permission. |
|
||||||
* |
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
#include <map> |
|
||||||
|
|
||||||
#include <node.h> |
|
||||||
#include <nan.h> |
|
||||||
#include "grpc/grpc.h" |
|
||||||
#include "byte_buffer.h" |
|
||||||
#include "call.h" |
|
||||||
#include "event.h" |
|
||||||
#include "tag.h" |
|
||||||
#include "timeval.h" |
|
||||||
|
|
||||||
namespace grpc { |
|
||||||
namespace node { |
|
||||||
|
|
||||||
using ::node::Buffer; |
|
||||||
using v8::Array; |
|
||||||
using v8::Date; |
|
||||||
using v8::Handle; |
|
||||||
using v8::HandleScope; |
|
||||||
using v8::Number; |
|
||||||
using v8::Object; |
|
||||||
using v8::Persistent; |
|
||||||
using v8::String; |
|
||||||
using v8::Value; |
|
||||||
|
|
||||||
Handle<Value> ParseMetadata(grpc_metadata *metadata_elements, size_t length) { |
|
||||||
NanEscapableScope(); |
|
||||||
std::map<const char*, size_t> size_map; |
|
||||||
std::map<const char*, size_t> index_map; |
|
||||||
|
|
||||||
for (unsigned int i = 0; i < length; i++) { |
|
||||||
const char *key = metadata_elements[i].key; |
|
||||||
if (size_map.count(key)) { |
|
||||||
size_map[key] += 1; |
|
||||||
} |
|
||||||
index_map[key] = 0; |
|
||||||
} |
|
||||||
Handle<Object> metadata_object = NanNew<Object>(); |
|
||||||
for (unsigned int i = 0; i < length; i++) { |
|
||||||
grpc_metadata* elem = &metadata_elements[i]; |
|
||||||
Handle<String> key_string = String::New(elem->key); |
|
||||||
Handle<Array> array; |
|
||||||
if (metadata_object->Has(key_string)) { |
|
||||||
array = Handle<Array>::Cast(metadata_object->Get(key_string)); |
|
||||||
} else { |
|
||||||
array = NanNew<Array>(size_map[elem->key]); |
|
||||||
metadata_object->Set(key_string, array); |
|
||||||
} |
|
||||||
array->Set(index_map[elem->key], |
|
||||||
MakeFastBuffer( |
|
||||||
NanNewBufferHandle(elem->value, elem->value_length))); |
|
||||||
index_map[elem->key] += 1; |
|
||||||
} |
|
||||||
return NanEscapeScope(metadata_object); |
|
||||||
} |
|
||||||
|
|
||||||
Handle<Value> GetEventData(grpc_event *event) { |
|
||||||
NanEscapableScope(); |
|
||||||
size_t count; |
|
||||||
grpc_metadata *items; |
|
||||||
Handle<Array> metadata; |
|
||||||
Handle<Object> status; |
|
||||||
Handle<Object> rpc_new; |
|
||||||
switch (event->type) { |
|
||||||
case GRPC_READ: |
|
||||||
return NanEscapeScope(ByteBufferToBuffer(event->data.read)); |
|
||||||
case GRPC_WRITE_ACCEPTED: |
|
||||||
return NanEscapeScope(NanNew<Number>(event->data.write_accepted)); |
|
||||||
case GRPC_FINISH_ACCEPTED: |
|
||||||
return NanEscapeScope(NanNew<Number>(event->data.finish_accepted)); |
|
||||||
case GRPC_CLIENT_METADATA_READ: |
|
||||||
count = event->data.client_metadata_read.count; |
|
||||||
items = event->data.client_metadata_read.elements; |
|
||||||
return NanEscapeScope(ParseMetadata(items, count)); |
|
||||||
case GRPC_FINISHED: |
|
||||||
status = NanNew<Object>(); |
|
||||||
status->Set(NanNew("code"), NanNew<Number>(event->data.finished.status)); |
|
||||||
if (event->data.finished.details != NULL) { |
|
||||||
status->Set(NanNew("details"), |
|
||||||
String::New(event->data.finished.details)); |
|
||||||
} |
|
||||||
count = event->data.finished.metadata_count; |
|
||||||
items = event->data.finished.metadata_elements; |
|
||||||
status->Set(NanNew("metadata"), ParseMetadata(items, count)); |
|
||||||
return NanEscapeScope(status); |
|
||||||
case GRPC_SERVER_RPC_NEW: |
|
||||||
rpc_new = NanNew<Object>(); |
|
||||||
if (event->data.server_rpc_new.method == NULL) { |
|
||||||
return NanEscapeScope(NanNull()); |
|
||||||
} |
|
||||||
rpc_new->Set( |
|
||||||
NanNew("method"), |
|
||||||
NanNew(event->data.server_rpc_new.method)); |
|
||||||
rpc_new->Set( |
|
||||||
NanNew("host"), |
|
||||||
NanNew(event->data.server_rpc_new.host)); |
|
||||||
rpc_new->Set(NanNew("absolute_deadline"), |
|
||||||
NanNew<Date>(TimespecToMilliseconds( |
|
||||||
event->data.server_rpc_new.deadline))); |
|
||||||
count = event->data.server_rpc_new.metadata_count; |
|
||||||
items = event->data.server_rpc_new.metadata_elements; |
|
||||||
metadata = NanNew<Array>(static_cast<int>(count)); |
|
||||||
for (unsigned int i = 0; i < count; i++) { |
|
||||||
Handle<Object> item_obj = Object::New(); |
|
||||||
item_obj->Set(NanNew("key"), |
|
||||||
NanNew(items[i].key)); |
|
||||||
item_obj->Set( |
|
||||||
NanNew("value"), |
|
||||||
NanNew(items[i].value, static_cast<int>(items[i].value_length))); |
|
||||||
metadata->Set(i, item_obj); |
|
||||||
} |
|
||||||
rpc_new->Set(NanNew("metadata"), ParseMetadata(items, count)); |
|
||||||
return NanEscapeScope(rpc_new); |
|
||||||
default: |
|
||||||
return NanEscapeScope(NanNull()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
Handle<Value> CreateEventObject(grpc_event *event) { |
|
||||||
NanEscapableScope(); |
|
||||||
if (event == NULL) { |
|
||||||
return NanEscapeScope(NanNull()); |
|
||||||
} |
|
||||||
Handle<Object> event_obj = NanNew<Object>(); |
|
||||||
Handle<Value> call; |
|
||||||
if (TagHasCall(event->tag)) { |
|
||||||
call = TagGetCall(event->tag); |
|
||||||
} else { |
|
||||||
call = Call::WrapStruct(event->call); |
|
||||||
} |
|
||||||
event_obj->Set(NanNew<String, const char *>("call"), call); |
|
||||||
event_obj->Set(NanNew<String, const char *>("type"), |
|
||||||
NanNew<Number>(event->type)); |
|
||||||
event_obj->Set(NanNew<String, const char *>("data"), GetEventData(event)); |
|
||||||
|
|
||||||
return NanEscapeScope(event_obj); |
|
||||||
} |
|
||||||
|
|
||||||
} // namespace node
|
|
||||||
} // namespace grpc
|
|
@ -1,101 +0,0 @@ |
|||||||
/*
|
|
||||||
* |
|
||||||
* Copyright 2014, 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 <stdlib.h> |
|
||||||
#include <node.h> |
|
||||||
#include <nan.h> |
|
||||||
#include "tag.h" |
|
||||||
|
|
||||||
namespace grpc { |
|
||||||
namespace node { |
|
||||||
|
|
||||||
using v8::Handle; |
|
||||||
using v8::HandleScope; |
|
||||||
using v8::Persistent; |
|
||||||
using v8::Value; |
|
||||||
|
|
||||||
struct tag { |
|
||||||
tag(Persistent<Value> *tag, Persistent<Value> *call) |
|
||||||
: persist_tag(tag), persist_call(call) {} |
|
||||||
|
|
||||||
~tag() { |
|
||||||
persist_tag->Dispose(); |
|
||||||
if (persist_call != NULL) { |
|
||||||
persist_call->Dispose(); |
|
||||||
} |
|
||||||
} |
|
||||||
Persistent<Value> *persist_tag; |
|
||||||
Persistent<Value> *persist_call; |
|
||||||
}; |
|
||||||
|
|
||||||
void *CreateTag(Handle<Value> tag, Handle<Value> call) { |
|
||||||
NanScope(); |
|
||||||
Persistent<Value> *persist_tag = new Persistent<Value>(); |
|
||||||
NanAssignPersistent(*persist_tag, tag); |
|
||||||
Persistent<Value> *persist_call; |
|
||||||
if (call->IsNull() || call->IsUndefined()) { |
|
||||||
persist_call = NULL; |
|
||||||
} else { |
|
||||||
persist_call = new Persistent<Value>(); |
|
||||||
NanAssignPersistent(*persist_call, call); |
|
||||||
} |
|
||||||
struct tag *tag_struct = new struct tag(persist_tag, persist_call); |
|
||||||
return reinterpret_cast<void *>(tag_struct); |
|
||||||
} |
|
||||||
|
|
||||||
Handle<Value> GetTagHandle(void *tag) { |
|
||||||
NanEscapableScope(); |
|
||||||
struct tag *tag_struct = reinterpret_cast<struct tag *>(tag); |
|
||||||
Handle<Value> tag_value = NanNew<Value>(*tag_struct->persist_tag); |
|
||||||
return NanEscapeScope(tag_value); |
|
||||||
} |
|
||||||
|
|
||||||
bool TagHasCall(void *tag) { |
|
||||||
struct tag *tag_struct = reinterpret_cast<struct tag *>(tag); |
|
||||||
return tag_struct->persist_call != NULL; |
|
||||||
} |
|
||||||
|
|
||||||
Handle<Value> TagGetCall(void *tag) { |
|
||||||
NanEscapableScope(); |
|
||||||
struct tag *tag_struct = reinterpret_cast<struct tag *>(tag); |
|
||||||
if (tag_struct->persist_call == NULL) { |
|
||||||
return NanEscapeScope(NanNull()); |
|
||||||
} |
|
||||||
Handle<Value> call_value = NanNew<Value>(*tag_struct->persist_call); |
|
||||||
return NanEscapeScope(call_value); |
|
||||||
} |
|
||||||
|
|
||||||
void DestroyTag(void *tag) { delete reinterpret_cast<struct tag *>(tag); } |
|
||||||
|
|
||||||
} // namespace node
|
|
||||||
} // namespace grpc
|
|
@ -1,59 +0,0 @@ |
|||||||
/*
|
|
||||||
* |
|
||||||
* Copyright 2014, 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 NET_GRPC_NODE_TAG_H_ |
|
||||||
#define NET_GRPC_NODE_TAG_H_ |
|
||||||
|
|
||||||
#include <node.h> |
|
||||||
|
|
||||||
namespace grpc { |
|
||||||
namespace node { |
|
||||||
|
|
||||||
/* Create a void* tag that can be passed to various grpc_call functions from
|
|
||||||
a javascript value and the javascript wrapper for the call. The call can be |
|
||||||
null. */ |
|
||||||
void *CreateTag(v8::Handle<v8::Value> tag, v8::Handle<v8::Value> call); |
|
||||||
/* Return the javascript value stored in the tag */ |
|
||||||
v8::Handle<v8::Value> GetTagHandle(void *tag); |
|
||||||
/* Returns true if the call was set (non-null) when the tag was created */ |
|
||||||
bool TagHasCall(void *tag); |
|
||||||
/* Returns the javascript wrapper for the call associated with this tag */ |
|
||||||
v8::Handle<v8::Value> TagGetCall(void *call); |
|
||||||
/* Destroy the tag and all resources it is holding. It is illegal to call any
|
|
||||||
of these other functions on a tag after it has been destroyed. */ |
|
||||||
void DestroyTag(void *tag); |
|
||||||
|
|
||||||
} // namespace node
|
|
||||||
} // namespace grpc
|
|
||||||
|
|
||||||
#endif // NET_GRPC_NODE_TAG_H_
|
|
@ -1,357 +0,0 @@ |
|||||||
/* |
|
||||||
* |
|
||||||
* Copyright 2014, 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. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
var _ = require('underscore'); |
|
||||||
|
|
||||||
var capitalize = require('underscore.string/capitalize'); |
|
||||||
var decapitalize = require('underscore.string/decapitalize'); |
|
||||||
|
|
||||||
var client = require('./client.js'); |
|
||||||
|
|
||||||
var common = require('./common.js'); |
|
||||||
|
|
||||||
var EventEmitter = require('events').EventEmitter; |
|
||||||
|
|
||||||
var stream = require('stream'); |
|
||||||
|
|
||||||
var Readable = stream.Readable; |
|
||||||
var Writable = stream.Writable; |
|
||||||
var Duplex = stream.Duplex; |
|
||||||
var util = require('util'); |
|
||||||
|
|
||||||
|
|
||||||
function forwardEvent(fromEmitter, toEmitter, event) { |
|
||||||
fromEmitter.on(event, function forward() { |
|
||||||
_.partial(toEmitter.emit, event).apply(toEmitter, arguments); |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
util.inherits(ClientReadableObjectStream, Readable); |
|
||||||
|
|
||||||
/** |
|
||||||
* Class for representing a gRPC server streaming call as a Node stream on the |
|
||||||
* client side. Extends from stream.Readable. |
|
||||||
* @constructor |
|
||||||
* @param {stream} stream Underlying binary Duplex stream for the call |
|
||||||
*/ |
|
||||||
function ClientReadableObjectStream(stream) { |
|
||||||
var options = {objectMode: true}; |
|
||||||
Readable.call(this, options); |
|
||||||
this._stream = stream; |
|
||||||
var self = this; |
|
||||||
forwardEvent(stream, this, 'status'); |
|
||||||
forwardEvent(stream, this, 'metadata'); |
|
||||||
this._stream.on('data', function forwardData(chunk) { |
|
||||||
if (!self.push(chunk)) { |
|
||||||
self._stream.pause(); |
|
||||||
} |
|
||||||
}); |
|
||||||
this._stream.pause(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* _read implementation for both types of streams that allow reading. |
|
||||||
* @this {ClientReadableObjectStream} |
|
||||||
* @param {number} size Ignored |
|
||||||
*/ |
|
||||||
function _read(size) { |
|
||||||
this._stream.resume(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* See docs for _read |
|
||||||
*/ |
|
||||||
ClientReadableObjectStream.prototype._read = _read; |
|
||||||
|
|
||||||
util.inherits(ClientWritableObjectStream, Writable); |
|
||||||
|
|
||||||
/** |
|
||||||
* Class for representing a gRPC client streaming call as a Node stream on the |
|
||||||
* client side. Extends from stream.Writable. |
|
||||||
* @constructor |
|
||||||
* @param {stream} stream Underlying binary Duplex stream for the call |
|
||||||
*/ |
|
||||||
function ClientWritableObjectStream(stream) { |
|
||||||
var options = {objectMode: true}; |
|
||||||
Writable.call(this, options); |
|
||||||
this._stream = stream; |
|
||||||
forwardEvent(stream, this, 'status'); |
|
||||||
forwardEvent(stream, this, 'metadata'); |
|
||||||
this.on('finish', function() { |
|
||||||
this._stream.end(); |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* _write implementation for both types of streams that allow writing |
|
||||||
* @this {ClientWritableObjectStream} |
|
||||||
* @param {*} chunk The value to write to the stream |
|
||||||
* @param {string} encoding Ignored |
|
||||||
* @param {function(Error)} callback Callback to call when finished writing |
|
||||||
*/ |
|
||||||
function _write(chunk, encoding, callback) { |
|
||||||
this._stream.write(chunk, encoding, callback); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* See docs for _write |
|
||||||
*/ |
|
||||||
ClientWritableObjectStream.prototype._write = _write; |
|
||||||
|
|
||||||
/** |
|
||||||
* Cancel the underlying call |
|
||||||
*/ |
|
||||||
function cancel() { |
|
||||||
this._stream.cancel(); |
|
||||||
} |
|
||||||
|
|
||||||
ClientReadableObjectStream.prototype.cancel = cancel; |
|
||||||
ClientWritableObjectStream.prototype.cancel = cancel; |
|
||||||
|
|
||||||
/** |
|
||||||
* Get a function that can make unary requests to the specified method. |
|
||||||
* @param {string} method The name of the method to request |
|
||||||
* @param {function(*):Buffer} serialize The serialization function for inputs |
|
||||||
* @param {function(Buffer)} deserialize The deserialization function for |
|
||||||
* outputs |
|
||||||
* @return {Function} makeUnaryRequest |
|
||||||
*/ |
|
||||||
function makeUnaryRequestFunction(method, serialize, deserialize) { |
|
||||||
/** |
|
||||||
* Make a unary request with this method on the given channel with the given |
|
||||||
* argument, callback, etc. |
|
||||||
* @this {SurfaceClient} Client object. Must have a channel member. |
|
||||||
* @param {*} argument The argument to the call. Should be serializable with |
|
||||||
* serialize |
|
||||||
* @param {function(?Error, value=)} callback The callback to for when the |
|
||||||
* response is received |
|
||||||
* @param {array=} metadata Array of metadata key/value pairs to add to the |
|
||||||
* call |
|
||||||
* @param {(number|Date)=} deadline The deadline for processing this request. |
|
||||||
* Defaults to infinite future |
|
||||||
* @return {EventEmitter} An event emitter for stream related events |
|
||||||
*/ |
|
||||||
function makeUnaryRequest(argument, callback, metadata, deadline) { |
|
||||||
var stream = client.makeRequest(this.channel, method, serialize, |
|
||||||
deserialize, metadata, deadline); |
|
||||||
var emitter = new EventEmitter(); |
|
||||||
emitter.cancel = function cancel() { |
|
||||||
stream.cancel(); |
|
||||||
}; |
|
||||||
forwardEvent(stream, emitter, 'status'); |
|
||||||
forwardEvent(stream, emitter, 'metadata'); |
|
||||||
stream.write(argument); |
|
||||||
stream.end(); |
|
||||||
stream.on('data', function forwardData(chunk) { |
|
||||||
try { |
|
||||||
callback(null, chunk); |
|
||||||
} catch (e) { |
|
||||||
callback(e); |
|
||||||
} |
|
||||||
}); |
|
||||||
stream.on('status', function forwardStatus(status) { |
|
||||||
if (status.code !== client.status.OK) { |
|
||||||
callback(status); |
|
||||||
} |
|
||||||
}); |
|
||||||
return emitter; |
|
||||||
} |
|
||||||
return makeUnaryRequest; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get a function that can make client stream requests to the specified method. |
|
||||||
* @param {string} method The name of the method to request |
|
||||||
* @param {function(*):Buffer} serialize The serialization function for inputs |
|
||||||
* @param {function(Buffer)} deserialize The deserialization function for |
|
||||||
* outputs |
|
||||||
* @return {Function} makeClientStreamRequest |
|
||||||
*/ |
|
||||||
function makeClientStreamRequestFunction(method, serialize, deserialize) { |
|
||||||
/** |
|
||||||
* Make a client stream request with this method on the given channel with the |
|
||||||
* given callback, etc. |
|
||||||
* @this {SurfaceClient} Client object. Must have a channel member. |
|
||||||
* @param {function(?Error, value=)} callback The callback to for when the |
|
||||||
* response is received |
|
||||||
* @param {array=} metadata Array of metadata key/value pairs to add to the |
|
||||||
* call |
|
||||||
* @param {(number|Date)=} deadline The deadline for processing this request. |
|
||||||
* Defaults to infinite future |
|
||||||
* @return {EventEmitter} An event emitter for stream related events |
|
||||||
*/ |
|
||||||
function makeClientStreamRequest(callback, metadata, deadline) { |
|
||||||
var stream = client.makeRequest(this.channel, method, serialize, |
|
||||||
deserialize, metadata, deadline); |
|
||||||
var obj_stream = new ClientWritableObjectStream(stream); |
|
||||||
stream.on('data', function forwardData(chunk) { |
|
||||||
try { |
|
||||||
callback(null, chunk); |
|
||||||
} catch (e) { |
|
||||||
callback(e); |
|
||||||
} |
|
||||||
}); |
|
||||||
stream.on('status', function forwardStatus(status) { |
|
||||||
if (status.code !== client.status.OK) { |
|
||||||
callback(status); |
|
||||||
} |
|
||||||
}); |
|
||||||
return obj_stream; |
|
||||||
} |
|
||||||
return makeClientStreamRequest; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get a function that can make server stream requests to the specified method. |
|
||||||
* @param {string} method The name of the method to request |
|
||||||
* @param {function(*):Buffer} serialize The serialization function for inputs |
|
||||||
* @param {function(Buffer)} deserialize The deserialization function for |
|
||||||
* outputs |
|
||||||
* @return {Function} makeServerStreamRequest |
|
||||||
*/ |
|
||||||
function makeServerStreamRequestFunction(method, serialize, deserialize) { |
|
||||||
/** |
|
||||||
* Make a server stream request with this method on the given channel with the |
|
||||||
* given argument, etc. |
|
||||||
* @this {SurfaceClient} Client object. Must have a channel member. |
|
||||||
* @param {*} argument The argument to the call. Should be serializable with |
|
||||||
* serialize |
|
||||||
* @param {array=} metadata Array of metadata key/value pairs to add to the |
|
||||||
* call |
|
||||||
* @param {(number|Date)=} deadline The deadline for processing this request. |
|
||||||
* Defaults to infinite future |
|
||||||
* @return {EventEmitter} An event emitter for stream related events |
|
||||||
*/ |
|
||||||
function makeServerStreamRequest(argument, metadata, deadline) { |
|
||||||
var stream = client.makeRequest(this.channel, method, serialize, |
|
||||||
deserialize, metadata, deadline); |
|
||||||
var obj_stream = new ClientReadableObjectStream(stream); |
|
||||||
stream.write(argument); |
|
||||||
stream.end(); |
|
||||||
return obj_stream; |
|
||||||
} |
|
||||||
return makeServerStreamRequest; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Get a function that can make bidirectional stream requests to the specified |
|
||||||
* method. |
|
||||||
* @param {string} method The name of the method to request |
|
||||||
* @param {function(*):Buffer} serialize The serialization function for inputs |
|
||||||
* @param {function(Buffer)} deserialize The deserialization function for |
|
||||||
* outputs |
|
||||||
* @return {Function} makeBidiStreamRequest |
|
||||||
*/ |
|
||||||
function makeBidiStreamRequestFunction(method, serialize, deserialize) { |
|
||||||
/** |
|
||||||
* Make a bidirectional stream request with this method on the given channel. |
|
||||||
* @this {SurfaceClient} Client object. Must have a channel member. |
|
||||||
* @param {array=} metadata Array of metadata key/value pairs to add to the |
|
||||||
* call |
|
||||||
* @param {(number|Date)=} deadline The deadline for processing this request. |
|
||||||
* Defaults to infinite future |
|
||||||
* @return {EventEmitter} An event emitter for stream related events |
|
||||||
*/ |
|
||||||
function makeBidiStreamRequest(metadata, deadline) { |
|
||||||
return client.makeRequest(this.channel, method, serialize, |
|
||||||
deserialize, metadata, deadline); |
|
||||||
} |
|
||||||
return makeBidiStreamRequest; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Map with short names for each of the requester maker functions. Used in |
|
||||||
* makeClientConstructor |
|
||||||
*/ |
|
||||||
var requester_makers = { |
|
||||||
unary: makeUnaryRequestFunction, |
|
||||||
server_stream: makeServerStreamRequestFunction, |
|
||||||
client_stream: makeClientStreamRequestFunction, |
|
||||||
bidi: makeBidiStreamRequestFunction |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Creates a constructor for clients for the given service |
|
||||||
* @param {ProtoBuf.Reflect.Service} service The service to generate a client |
|
||||||
* for |
|
||||||
* @return {function(string, Object)} New client constructor |
|
||||||
*/ |
|
||||||
function makeClientConstructor(service) { |
|
||||||
var prefix = '/' + common.fullyQualifiedName(service) + '/'; |
|
||||||
/** |
|
||||||
* Create a client with the given methods |
|
||||||
* @constructor |
|
||||||
* @param {string} address The address of the server to connect to |
|
||||||
* @param {Object} options Options to pass to the underlying channel |
|
||||||
*/ |
|
||||||
function SurfaceClient(address, options) { |
|
||||||
this.channel = new client.Channel(address, options); |
|
||||||
} |
|
||||||
|
|
||||||
_.each(service.children, function(method) { |
|
||||||
var method_type; |
|
||||||
if (method.requestStream) { |
|
||||||
if (method.responseStream) { |
|
||||||
method_type = 'bidi'; |
|
||||||
} else { |
|
||||||
method_type = 'client_stream'; |
|
||||||
} |
|
||||||
} else { |
|
||||||
if (method.responseStream) { |
|
||||||
method_type = 'server_stream'; |
|
||||||
} else { |
|
||||||
method_type = 'unary'; |
|
||||||
} |
|
||||||
} |
|
||||||
SurfaceClient.prototype[decapitalize(method.name)] = |
|
||||||
requester_makers[method_type]( |
|
||||||
prefix + capitalize(method.name), |
|
||||||
common.serializeCls(method.resolvedRequestType.build()), |
|
||||||
common.deserializeCls(method.resolvedResponseType.build())); |
|
||||||
}); |
|
||||||
|
|
||||||
SurfaceClient.service = service; |
|
||||||
|
|
||||||
return SurfaceClient; |
|
||||||
} |
|
||||||
|
|
||||||
exports.makeClientConstructor = makeClientConstructor; |
|
||||||
|
|
||||||
/** |
|
||||||
* See docs for client.status |
|
||||||
*/ |
|
||||||
exports.status = client.status; |
|
||||||
/** |
|
||||||
* See docs for client.callError |
|
||||||
*/ |
|
||||||
exports.callError = client.callError; |
|
@ -1,340 +0,0 @@ |
|||||||
/* |
|
||||||
* |
|
||||||
* Copyright 2014, 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. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
var _ = require('underscore'); |
|
||||||
|
|
||||||
var capitalize = require('underscore.string/capitalize'); |
|
||||||
var decapitalize = require('underscore.string/decapitalize'); |
|
||||||
|
|
||||||
var Server = require('./server.js'); |
|
||||||
|
|
||||||
var stream = require('stream'); |
|
||||||
|
|
||||||
var Readable = stream.Readable; |
|
||||||
var Writable = stream.Writable; |
|
||||||
var Duplex = stream.Duplex; |
|
||||||
var util = require('util'); |
|
||||||
|
|
||||||
var common = require('./common.js'); |
|
||||||
|
|
||||||
util.inherits(ServerReadableObjectStream, Readable); |
|
||||||
|
|
||||||
/** |
|
||||||
* Class for representing a gRPC client streaming call as a Node stream on the |
|
||||||
* server side. Extends from stream.Readable. |
|
||||||
* @constructor |
|
||||||
* @param {stream} stream Underlying binary Duplex stream for the call |
|
||||||
*/ |
|
||||||
function ServerReadableObjectStream(stream) { |
|
||||||
var options = {objectMode: true}; |
|
||||||
Readable.call(this, options); |
|
||||||
this._stream = stream; |
|
||||||
Object.defineProperty(this, 'cancelled', { |
|
||||||
get: function() { return stream.cancelled; } |
|
||||||
}); |
|
||||||
var self = this; |
|
||||||
this._stream.on('cancelled', function() { |
|
||||||
self.emit('cancelled'); |
|
||||||
}); |
|
||||||
this._stream.on('data', function forwardData(chunk) { |
|
||||||
if (!self.push(chunk)) { |
|
||||||
self._stream.pause(); |
|
||||||
} |
|
||||||
}); |
|
||||||
this._stream.on('end', function forwardEnd() { |
|
||||||
self.push(null); |
|
||||||
}); |
|
||||||
this._stream.pause(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* _read implementation for both types of streams that allow reading. |
|
||||||
* @this {ServerReadableObjectStream|ServerBidiObjectStream} |
|
||||||
* @param {number} size Ignored |
|
||||||
*/ |
|
||||||
function _read(size) { |
|
||||||
this._stream.resume(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* See docs for _read |
|
||||||
*/ |
|
||||||
ServerReadableObjectStream.prototype._read = _read; |
|
||||||
|
|
||||||
util.inherits(ServerWritableObjectStream, Writable); |
|
||||||
|
|
||||||
/** |
|
||||||
* Class for representing a gRPC server streaming call as a Node stream on the |
|
||||||
* server side. Extends from stream.Writable. |
|
||||||
* @constructor |
|
||||||
* @param {stream} stream Underlying binary Duplex stream for the call |
|
||||||
*/ |
|
||||||
function ServerWritableObjectStream(stream) { |
|
||||||
var options = {objectMode: true}; |
|
||||||
Writable.call(this, options); |
|
||||||
this._stream = stream; |
|
||||||
this._stream.on('cancelled', function() { |
|
||||||
self.emit('cancelled'); |
|
||||||
}); |
|
||||||
this.on('finish', function() { |
|
||||||
this._stream.end(); |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* _write implementation for both types of streams that allow writing |
|
||||||
* @this {ServerWritableObjectStream} |
|
||||||
* @param {*} chunk The value to write to the stream |
|
||||||
* @param {string} encoding Ignored |
|
||||||
* @param {function(Error)} callback Callback to call when finished writing |
|
||||||
*/ |
|
||||||
function _write(chunk, encoding, callback) { |
|
||||||
this._stream.write(chunk, encoding, callback); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* See docs for _write |
|
||||||
*/ |
|
||||||
ServerWritableObjectStream.prototype._write = _write; |
|
||||||
|
|
||||||
/** |
|
||||||
* Creates a binary stream handler function from a unary handler function |
|
||||||
* @param {function(Object, function(Error, *), metadata=)} handler Unary call |
|
||||||
* handler |
|
||||||
* @return {function(stream, metadata=)} Binary stream handler |
|
||||||
*/ |
|
||||||
function makeUnaryHandler(handler) { |
|
||||||
/** |
|
||||||
* Handles a stream by reading a single data value, passing it to the handler, |
|
||||||
* and writing the response back to the stream. |
|
||||||
* @param {stream} stream Binary data stream |
|
||||||
* @param {metadata=} metadata Incoming metadata array |
|
||||||
*/ |
|
||||||
return function handleUnaryCall(stream, metadata) { |
|
||||||
stream.on('data', function handleUnaryData(value) { |
|
||||||
var call = {request: value}; |
|
||||||
Object.defineProperty(call, 'cancelled', { |
|
||||||
get: function() { return stream.cancelled;} |
|
||||||
}); |
|
||||||
stream.on('cancelled', function() { |
|
||||||
call.emit('cancelled'); |
|
||||||
}); |
|
||||||
handler(call, function sendUnaryData(err, value) { |
|
||||||
if (err) { |
|
||||||
stream.emit('error', err); |
|
||||||
} else { |
|
||||||
stream.write(value); |
|
||||||
stream.end(); |
|
||||||
} |
|
||||||
}, metadata); |
|
||||||
}); |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Creates a binary stream handler function from a client stream handler |
|
||||||
* function |
|
||||||
* @param {function(Readable, function(Error, *), metadata=)} handler Client |
|
||||||
* stream call handler |
|
||||||
* @return {function(stream, metadata=)} Binary stream handler |
|
||||||
*/ |
|
||||||
function makeClientStreamHandler(handler) { |
|
||||||
/** |
|
||||||
* Handles a stream by passing a deserializing stream to the handler and |
|
||||||
* writing the response back to the stream. |
|
||||||
* @param {stream} stream Binary data stream |
|
||||||
* @param {metadata=} metadata Incoming metadata array |
|
||||||
*/ |
|
||||||
return function handleClientStreamCall(stream, metadata) { |
|
||||||
var object_stream = new ServerReadableObjectStream(stream); |
|
||||||
handler(object_stream, function sendClientStreamData(err, value) { |
|
||||||
if (err) { |
|
||||||
stream.emit('error', err); |
|
||||||
} else { |
|
||||||
stream.write(value); |
|
||||||
stream.end(); |
|
||||||
} |
|
||||||
}, metadata); |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Creates a binary stream handler function from a server stream handler |
|
||||||
* function |
|
||||||
* @param {function(Writable, metadata=)} handler Server stream call handler |
|
||||||
* @return {function(stream, metadata=)} Binary stream handler |
|
||||||
*/ |
|
||||||
function makeServerStreamHandler(handler) { |
|
||||||
/** |
|
||||||
* Handles a stream by attaching it to a serializing stream, and passing it to |
|
||||||
* the handler. |
|
||||||
* @param {stream} stream Binary data stream |
|
||||||
* @param {metadata=} metadata Incoming metadata array |
|
||||||
*/ |
|
||||||
return function handleServerStreamCall(stream, metadata) { |
|
||||||
stream.on('data', function handleClientData(value) { |
|
||||||
var object_stream = new ServerWritableObjectStream(stream); |
|
||||||
object_stream.request = value; |
|
||||||
handler(object_stream, metadata); |
|
||||||
}); |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Creates a binary stream handler function from a bidi stream handler function |
|
||||||
* @param {function(Duplex, metadata=)} handler Unary call handler |
|
||||||
* @return {function(stream, metadata=)} Binary stream handler |
|
||||||
*/ |
|
||||||
function makeBidiStreamHandler(handler) { |
|
||||||
return handler; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Map with short names for each of the handler maker functions. Used in |
|
||||||
* makeServerConstructor |
|
||||||
*/ |
|
||||||
var handler_makers = { |
|
||||||
unary: makeUnaryHandler, |
|
||||||
server_stream: makeServerStreamHandler, |
|
||||||
client_stream: makeClientStreamHandler, |
|
||||||
bidi: makeBidiStreamHandler |
|
||||||
}; |
|
||||||
|
|
||||||
/** |
|
||||||
* Creates a constructor for servers with a service defined by the methods |
|
||||||
* object. The methods object has string keys and values of this form: |
|
||||||
* {serialize: function, deserialize: function, client_stream: bool, |
|
||||||
* server_stream: bool} |
|
||||||
* @param {Object} methods Method descriptor for each method the server should |
|
||||||
* expose |
|
||||||
* @param {string} prefix The prefex to prepend to each method name |
|
||||||
* @return {function(Object, Object)} New server constructor |
|
||||||
*/ |
|
||||||
function makeServerConstructor(services) { |
|
||||||
var qual_names = []; |
|
||||||
_.each(services, function(service) { |
|
||||||
_.each(service.children, function(method) { |
|
||||||
var name = common.fullyQualifiedName(method); |
|
||||||
if (_.indexOf(qual_names, name) !== -1) { |
|
||||||
throw new Error('Method ' + name + ' exposed by more than one service'); |
|
||||||
} |
|
||||||
qual_names.push(name); |
|
||||||
}); |
|
||||||
}); |
|
||||||
/** |
|
||||||
* Create a server with the given handlers for all of the methods. |
|
||||||
* @constructor |
|
||||||
* @param {Object} service_handlers Map from service names to map from method |
|
||||||
* names to handlers |
|
||||||
* @param {function(string, Object<string, Array<Buffer>>): |
|
||||||
Object<string, Array<Buffer|string>>=} getMetadata Callback that |
|
||||||
* gets metatada for a given method |
|
||||||
* @param {Object=} options Options to pass to the underlying server |
|
||||||
*/ |
|
||||||
function SurfaceServer(service_handlers, getMetadata, options) { |
|
||||||
var server = new Server(getMetadata, options); |
|
||||||
this.inner_server = server; |
|
||||||
_.each(services, function(service) { |
|
||||||
var service_name = common.fullyQualifiedName(service); |
|
||||||
if (service_handlers[service_name] === undefined) { |
|
||||||
throw new Error('Handlers for service ' + |
|
||||||
service_name + ' not provided.'); |
|
||||||
} |
|
||||||
var prefix = '/' + common.fullyQualifiedName(service) + '/'; |
|
||||||
_.each(service.children, function(method) { |
|
||||||
var method_type; |
|
||||||
if (method.requestStream) { |
|
||||||
if (method.responseStream) { |
|
||||||
method_type = 'bidi'; |
|
||||||
} else { |
|
||||||
method_type = 'client_stream'; |
|
||||||
} |
|
||||||
} else { |
|
||||||
if (method.responseStream) { |
|
||||||
method_type = 'server_stream'; |
|
||||||
} else { |
|
||||||
method_type = 'unary'; |
|
||||||
} |
|
||||||
} |
|
||||||
if (service_handlers[service_name][decapitalize(method.name)] === |
|
||||||
undefined) { |
|
||||||
throw new Error('Method handler for ' + |
|
||||||
common.fullyQualifiedName(method) + ' not provided.'); |
|
||||||
} |
|
||||||
var binary_handler = handler_makers[method_type]( |
|
||||||
service_handlers[service_name][decapitalize(method.name)]); |
|
||||||
var serialize = common.serializeCls( |
|
||||||
method.resolvedResponseType.build()); |
|
||||||
var deserialize = common.deserializeCls( |
|
||||||
method.resolvedRequestType.build()); |
|
||||||
server.register(prefix + capitalize(method.name), binary_handler, |
|
||||||
serialize, deserialize); |
|
||||||
}); |
|
||||||
}, this); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Binds the server to the given port, with SSL enabled if secure is specified |
|
||||||
* @param {string} port The port that the server should bind on, in the format |
|
||||||
* "address:port" |
|
||||||
* @param {boolean=} secure Whether the server should open a secure port |
|
||||||
* @return {SurfaceServer} this |
|
||||||
*/ |
|
||||||
SurfaceServer.prototype.bind = function(port, secure) { |
|
||||||
return this.inner_server.bind(port, secure); |
|
||||||
}; |
|
||||||
|
|
||||||
/** |
|
||||||
* Starts the server listening on any bound ports |
|
||||||
* @return {SurfaceServer} this |
|
||||||
*/ |
|
||||||
SurfaceServer.prototype.listen = function() { |
|
||||||
this.inner_server.start(); |
|
||||||
return this; |
|
||||||
}; |
|
||||||
|
|
||||||
/** |
|
||||||
* Shuts the server down; tells it to stop listening for new requests and to |
|
||||||
* kill old requests. |
|
||||||
*/ |
|
||||||
SurfaceServer.prototype.shutdown = function() { |
|
||||||
this.inner_server.shutdown(); |
|
||||||
}; |
|
||||||
|
|
||||||
return SurfaceServer; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* See documentation for makeServerConstructor |
|
||||||
*/ |
|
||||||
exports.makeServerConstructor = makeServerConstructor; |
|
@ -1,255 +0,0 @@ |
|||||||
/* |
|
||||||
* |
|
||||||
* Copyright 2014, 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. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
var assert = require('assert'); |
|
||||||
var fs = require('fs'); |
|
||||||
var path = require('path'); |
|
||||||
var grpc = require('bindings')('grpc.node'); |
|
||||||
var Server = require('../src/server'); |
|
||||||
var client = require('../src/client'); |
|
||||||
var common = require('../src/common'); |
|
||||||
|
|
||||||
var ca_path = path.join(__dirname, 'data/ca.pem'); |
|
||||||
|
|
||||||
var key_path = path.join(__dirname, 'data/server1.key'); |
|
||||||
|
|
||||||
var pem_path = path.join(__dirname, 'data/server1.pem'); |
|
||||||
|
|
||||||
/** |
|
||||||
* Helper function to return an absolute deadline given a relative timeout in |
|
||||||
* seconds. |
|
||||||
* @param {number} timeout_secs The number of seconds to wait before timing out |
|
||||||
* @return {Date} A date timeout_secs in the future |
|
||||||
*/ |
|
||||||
function getDeadline(timeout_secs) { |
|
||||||
var deadline = new Date(); |
|
||||||
deadline.setSeconds(deadline.getSeconds() + timeout_secs); |
|
||||||
return deadline; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Responds to every request with the same data as a response |
|
||||||
* @param {Stream} stream |
|
||||||
*/ |
|
||||||
function echoHandler(stream) { |
|
||||||
stream.pipe(stream); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Responds to every request with an error status |
|
||||||
* @param {Stream} stream |
|
||||||
*/ |
|
||||||
function errorHandler(stream) { |
|
||||||
throw { |
|
||||||
'code' : grpc.status.UNIMPLEMENTED, |
|
||||||
'details' : 'error details' |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Wait for a cancellation instead of responding |
|
||||||
* @param {Stream} stream |
|
||||||
*/ |
|
||||||
function cancelHandler(stream) { |
|
||||||
// do nothing
|
|
||||||
} |
|
||||||
|
|
||||||
function metadataHandler(stream, metadata) { |
|
||||||
stream.end(); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Serialize a string to a Buffer |
|
||||||
* @param {string} value The string to serialize |
|
||||||
* @return {Buffer} The serialized value |
|
||||||
*/ |
|
||||||
function stringSerialize(value) { |
|
||||||
return new Buffer(value); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Deserialize a Buffer to a string |
|
||||||
* @param {Buffer} buffer The buffer to deserialize |
|
||||||
* @return {string} The string value of the buffer |
|
||||||
*/ |
|
||||||
function stringDeserialize(buffer) { |
|
||||||
return buffer.toString(); |
|
||||||
} |
|
||||||
|
|
||||||
describe('echo client', function() { |
|
||||||
var server; |
|
||||||
var channel; |
|
||||||
before(function() { |
|
||||||
server = new Server(function getMetadata(method, metadata) { |
|
||||||
return {method: [method]}; |
|
||||||
}); |
|
||||||
var port_num = server.bind('0.0.0.0:0'); |
|
||||||
server.register('echo', echoHandler); |
|
||||||
server.register('error', errorHandler); |
|
||||||
server.register('cancellation', cancelHandler); |
|
||||||
server.register('metadata', metadataHandler); |
|
||||||
server.start(); |
|
||||||
|
|
||||||
channel = new grpc.Channel('localhost:' + port_num); |
|
||||||
}); |
|
||||||
after(function() { |
|
||||||
server.shutdown(); |
|
||||||
}); |
|
||||||
it('should receive echo responses', function(done) { |
|
||||||
var messages = ['echo1', 'echo2', 'echo3', 'echo4']; |
|
||||||
var stream = client.makeRequest( |
|
||||||
channel, |
|
||||||
'echo', |
|
||||||
stringSerialize, |
|
||||||
stringDeserialize); |
|
||||||
for (var i = 0; i < messages.length; i++) { |
|
||||||
stream.write(messages[i]); |
|
||||||
} |
|
||||||
stream.end(); |
|
||||||
var index = 0; |
|
||||||
stream.on('data', function(chunk) { |
|
||||||
assert.equal(messages[index], chunk); |
|
||||||
index += 1; |
|
||||||
}); |
|
||||||
stream.on('status', function(status) { |
|
||||||
assert.equal(status.code, client.status.OK); |
|
||||||
}); |
|
||||||
stream.on('end', function() { |
|
||||||
assert.equal(index, messages.length); |
|
||||||
done(); |
|
||||||
}); |
|
||||||
}); |
|
||||||
it('should recieve metadata set by the server', function(done) { |
|
||||||
var stream = client.makeRequest(channel, 'metadata'); |
|
||||||
stream.on('metadata', function(metadata) { |
|
||||||
assert.strictEqual(metadata.method[0].toString(), 'metadata'); |
|
||||||
}); |
|
||||||
stream.on('status', function(status) { |
|
||||||
assert.equal(status.code, client.status.OK); |
|
||||||
done(); |
|
||||||
}); |
|
||||||
stream.end(); |
|
||||||
}); |
|
||||||
it('should get an error status that the server throws', function(done) { |
|
||||||
var stream = client.makeRequest(channel, 'error'); |
|
||||||
|
|
||||||
stream.on('data', function() {}); |
|
||||||
stream.write(new Buffer('test')); |
|
||||||
stream.end(); |
|
||||||
stream.on('status', function(status) { |
|
||||||
assert.equal(status.code, grpc.status.UNIMPLEMENTED); |
|
||||||
assert.equal(status.details, 'error details'); |
|
||||||
done(); |
|
||||||
}); |
|
||||||
}); |
|
||||||
it('should be able to cancel a call', function(done) { |
|
||||||
var stream = client.makeRequest( |
|
||||||
channel, |
|
||||||
'cancellation', |
|
||||||
null, |
|
||||||
getDeadline(1)); |
|
||||||
|
|
||||||
stream.cancel(); |
|
||||||
stream.on('status', function(status) { |
|
||||||
assert.equal(status.code, grpc.status.CANCELLED); |
|
||||||
done(); |
|
||||||
}); |
|
||||||
}); |
|
||||||
it('should get correct status for unimplemented method', function(done) { |
|
||||||
var stream = client.makeRequest(channel, 'unimplemented_method'); |
|
||||||
stream.end(); |
|
||||||
stream.on('status', function(status) { |
|
||||||
assert.equal(status.code, grpc.status.UNIMPLEMENTED); |
|
||||||
done(); |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
||||||
/* TODO(mlumish): explore options for reducing duplication between this test |
|
||||||
* and the insecure echo client test */ |
|
||||||
describe('secure echo client', function() { |
|
||||||
var server; |
|
||||||
var channel; |
|
||||||
before(function(done) { |
|
||||||
fs.readFile(ca_path, function(err, ca_data) { |
|
||||||
assert.ifError(err); |
|
||||||
fs.readFile(key_path, function(err, key_data) { |
|
||||||
assert.ifError(err); |
|
||||||
fs.readFile(pem_path, function(err, pem_data) { |
|
||||||
assert.ifError(err); |
|
||||||
var creds = grpc.Credentials.createSsl(ca_data); |
|
||||||
var server_creds = grpc.ServerCredentials.createSsl(null, |
|
||||||
key_data, |
|
||||||
pem_data); |
|
||||||
|
|
||||||
server = new Server(null, {'credentials' : server_creds}); |
|
||||||
var port_num = server.bind('0.0.0.0:0', true); |
|
||||||
server.register('echo', echoHandler); |
|
||||||
server.start(); |
|
||||||
|
|
||||||
channel = new grpc.Channel('localhost:' + port_num, { |
|
||||||
'grpc.ssl_target_name_override' : 'foo.test.google.com', |
|
||||||
'credentials' : creds |
|
||||||
}); |
|
||||||
done(); |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
||||||
after(function() { |
|
||||||
server.shutdown(); |
|
||||||
}); |
|
||||||
it('should recieve echo responses', function(done) { |
|
||||||
var messages = ['echo1', 'echo2', 'echo3', 'echo4']; |
|
||||||
var stream = client.makeRequest( |
|
||||||
channel, |
|
||||||
'echo', |
|
||||||
stringSerialize, |
|
||||||
stringDeserialize); |
|
||||||
for (var i = 0; i < messages.length; i++) { |
|
||||||
stream.write(messages[i]); |
|
||||||
} |
|
||||||
stream.end(); |
|
||||||
var index = 0; |
|
||||||
stream.on('data', function(chunk) { |
|
||||||
assert.equal(messages[index], chunk); |
|
||||||
index += 1; |
|
||||||
}); |
|
||||||
stream.on('status', function(status) { |
|
||||||
assert.equal(status.code, client.status.OK); |
|
||||||
}); |
|
||||||
stream.on('end', function() { |
|
||||||
assert.equal(index, messages.length); |
|
||||||
done(); |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
@ -1,122 +0,0 @@ |
|||||||
/* |
|
||||||
* |
|
||||||
* Copyright 2014, 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. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
var assert = require('assert'); |
|
||||||
var grpc = require('bindings')('grpc.node'); |
|
||||||
var Server = require('../src/server'); |
|
||||||
|
|
||||||
/** |
|
||||||
* This is used for testing functions with multiple asynchronous calls that |
|
||||||
* can happen in different orders. This should be passed the number of async |
|
||||||
* function invocations that can occur last, and each of those should call this |
|
||||||
* function's return value |
|
||||||
* @param {function()} done The function that should be called when a test is |
|
||||||
* complete. |
|
||||||
* @param {number} count The number of calls to the resulting function if the |
|
||||||
* test passes. |
|
||||||
* @return {function()} The function that should be called at the end of each |
|
||||||
* sequence of asynchronous functions. |
|
||||||
*/ |
|
||||||
function multiDone(done, count) { |
|
||||||
return function() { |
|
||||||
count -= 1; |
|
||||||
if (count <= 0) { |
|
||||||
done(); |
|
||||||
} |
|
||||||
}; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Responds to every request with the same data as a response |
|
||||||
* @param {Stream} stream |
|
||||||
*/ |
|
||||||
function echoHandler(stream) { |
|
||||||
stream.pipe(stream); |
|
||||||
} |
|
||||||
|
|
||||||
describe('echo server', function() { |
|
||||||
var server; |
|
||||||
var channel; |
|
||||||
before(function() { |
|
||||||
server = new Server(); |
|
||||||
var port_num = server.bind('[::]:0'); |
|
||||||
server.register('echo', echoHandler); |
|
||||||
server.start(); |
|
||||||
|
|
||||||
channel = new grpc.Channel('localhost:' + port_num); |
|
||||||
}); |
|
||||||
after(function() { |
|
||||||
server.shutdown(); |
|
||||||
}); |
|
||||||
it('should echo inputs as responses', function(done) { |
|
||||||
done = multiDone(done, 4); |
|
||||||
|
|
||||||
var req_text = 'echo test string'; |
|
||||||
var status_text = 'OK'; |
|
||||||
|
|
||||||
var deadline = new Date(); |
|
||||||
deadline.setSeconds(deadline.getSeconds() + 3); |
|
||||||
var call = new grpc.Call(channel, |
|
||||||
'echo', |
|
||||||
deadline); |
|
||||||
call.invoke(function(event) { |
|
||||||
assert.strictEqual(event.type, |
|
||||||
grpc.completionType.CLIENT_METADATA_READ); |
|
||||||
done(); |
|
||||||
},function(event) { |
|
||||||
assert.strictEqual(event.type, grpc.completionType.FINISHED); |
|
||||||
var status = event.data; |
|
||||||
assert.strictEqual(status.code, grpc.status.OK); |
|
||||||
assert.strictEqual(status.details, status_text); |
|
||||||
done(); |
|
||||||
}, 0); |
|
||||||
call.startWrite( |
|
||||||
new Buffer(req_text), |
|
||||||
function(event) { |
|
||||||
assert.strictEqual(event.type, |
|
||||||
grpc.completionType.WRITE_ACCEPTED); |
|
||||||
assert.strictEqual(event.data, grpc.opError.OK); |
|
||||||
call.writesDone(function(event) { |
|
||||||
assert.strictEqual(event.type, |
|
||||||
grpc.completionType.FINISH_ACCEPTED); |
|
||||||
assert.strictEqual(event.data, grpc.opError.OK); |
|
||||||
done(); |
|
||||||
}); |
|
||||||
}, 0); |
|
||||||
call.startRead(function(event) { |
|
||||||
assert.strictEqual(event.type, grpc.completionType.READ); |
|
||||||
assert.strictEqual(event.data.toString(), req_text); |
|
||||||
done(); |
|
||||||
}); |
|
||||||
}); |
|
||||||
}); |
|
@ -0,0 +1 @@ |
|||||||
|
These are test keys *NOT* to be used in production. |
@ -0,0 +1,16 @@ |
|||||||
|
-----BEGIN PRIVATE KEY----- |
||||||
|
MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAOHDFScoLCVJpYDD |
||||||
|
M4HYtIdV6Ake/sMNaaKdODjDMsux/4tDydlumN+fm+AjPEK5GHhGn1BgzkWF+slf |
||||||
|
3BxhrA/8dNsnunstVA7ZBgA/5qQxMfGAq4wHNVX77fBZOgp9VlSMVfyd9N8YwbBY |
||||||
|
AckOeUQadTi2X1S6OgJXgQ0m3MWhAgMBAAECgYAn7qGnM2vbjJNBm0VZCkOkTIWm |
||||||
|
V10okw7EPJrdL2mkre9NasghNXbE1y5zDshx5Nt3KsazKOxTT8d0Jwh/3KbaN+YY |
||||||
|
tTCbKGW0pXDRBhwUHRcuRzScjli8Rih5UOCiZkhefUTcRb6xIhZJuQy71tjaSy0p |
||||||
|
dHZRmYyBYO2YEQ8xoQJBAPrJPhMBkzmEYFtyIEqAxQ/o/A6E+E4w8i+KM7nQCK7q |
||||||
|
K4JXzyXVAjLfyBZWHGM2uro/fjqPggGD6QH1qXCkI4MCQQDmdKeb2TrKRh5BY1LR |
||||||
|
81aJGKcJ2XbcDu6wMZK4oqWbTX2KiYn9GB0woM6nSr/Y6iy1u145YzYxEV/iMwff |
||||||
|
DJULAkB8B2MnyzOg0pNFJqBJuH29bKCcHa8gHJzqXhNO5lAlEbMK95p/P2Wi+4Hd |
||||||
|
aiEIAF1BF326QJcvYKmwSmrORp85AkAlSNxRJ50OWrfMZnBgzVjDx3xG6KsFQVk2 |
||||||
|
ol6VhqL6dFgKUORFUWBvnKSyhjJxurlPEahV6oo6+A+mPhFY8eUvAkAZQyTdupP3 |
||||||
|
XEFQKctGz+9+gKkemDp7LBBMEMBXrGTLPhpEfcjv/7KPdnFHYmhYeBTBnuVmTVWe |
||||||
|
F98XJ7tIFfJq |
||||||
|
-----END PRIVATE KEY----- |
@ -0,0 +1,16 @@ |
|||||||
|
-----BEGIN CERTIFICATE----- |
||||||
|
MIICmzCCAgSgAwIBAgIBAzANBgkqhkiG9w0BAQUFADBWMQswCQYDVQQGEwJBVTET |
||||||
|
MBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQ |
||||||
|
dHkgTHRkMQ8wDQYDVQQDDAZ0ZXN0Y2EwHhcNMTQwNzIyMDYwMDU3WhcNMjQwNzE5 |
||||||
|
MDYwMDU3WjBkMQswCQYDVQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNV |
||||||
|
BAcTB0NoaWNhZ28xFDASBgNVBAoTC0dvb2dsZSBJbmMuMRowGAYDVQQDFBEqLnRl |
||||||
|
c3QuZ29vZ2xlLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA4cMVJygs |
||||||
|
JUmlgMMzgdi0h1XoCR7+ww1pop04OMMyy7H/i0PJ2W6Y35+b4CM8QrkYeEafUGDO |
||||||
|
RYX6yV/cHGGsD/x02ye6ey1UDtkGAD/mpDEx8YCrjAc1Vfvt8Fk6Cn1WVIxV/J30 |
||||||
|
3xjBsFgByQ55RBp1OLZfVLo6AleBDSbcxaECAwEAAaNrMGkwCQYDVR0TBAIwADAL |
||||||
|
BgNVHQ8EBAMCBeAwTwYDVR0RBEgwRoIQKi50ZXN0Lmdvb2dsZS5mcoIYd2F0ZXJ6 |
||||||
|
b29pLnRlc3QuZ29vZ2xlLmJlghIqLnRlc3QueW91dHViZS5jb22HBMCoAQMwDQYJ |
||||||
|
KoZIhvcNAQEFBQADgYEAM2Ii0LgTGbJ1j4oqX9bxVcxm+/R5Yf8oi0aZqTJlnLYS |
||||||
|
wXcBykxTx181s7WyfJ49WwrYXo78zTDAnf1ma0fPq3e4mpspvyndLh1a+OarHa1e |
||||||
|
aT0DIIYk7qeEa1YcVljx2KyLd0r1BBAfrwyGaEPVeJQVYWaOJRU2we/KD4ojf9s= |
||||||
|
-----END CERTIFICATE----- |
@ -0,0 +1,60 @@ |
|||||||
|
# Generated by the protocol buffer compiler. DO NOT EDIT! |
||||||
|
# source: test/cpp/interop/empty.proto |
||||||
|
|
||||||
|
import sys |
||||||
|
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) |
||||||
|
from google.protobuf import descriptor as _descriptor |
||||||
|
from google.protobuf import message as _message |
||||||
|
from google.protobuf import reflection as _reflection |
||||||
|
from google.protobuf import symbol_database as _symbol_database |
||||||
|
from google.protobuf import descriptor_pb2 |
||||||
|
# @@protoc_insertion_point(imports) |
||||||
|
|
||||||
|
_sym_db = _symbol_database.Default() |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTOR = _descriptor.FileDescriptor( |
||||||
|
name='test/cpp/interop/empty.proto', |
||||||
|
package='grpc.testing', |
||||||
|
serialized_pb=_b('\n\x1ctest/cpp/interop/empty.proto\x12\x0cgrpc.testing\"\x07\n\x05\x45mpty') |
||||||
|
) |
||||||
|
_sym_db.RegisterFileDescriptor(DESCRIPTOR) |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_EMPTY = _descriptor.Descriptor( |
||||||
|
name='Empty', |
||||||
|
full_name='grpc.testing.Empty', |
||||||
|
filename=None, |
||||||
|
file=DESCRIPTOR, |
||||||
|
containing_type=None, |
||||||
|
fields=[ |
||||||
|
], |
||||||
|
extensions=[ |
||||||
|
], |
||||||
|
nested_types=[], |
||||||
|
enum_types=[ |
||||||
|
], |
||||||
|
options=None, |
||||||
|
is_extendable=False, |
||||||
|
extension_ranges=[], |
||||||
|
oneofs=[ |
||||||
|
], |
||||||
|
serialized_start=46, |
||||||
|
serialized_end=53, |
||||||
|
) |
||||||
|
|
||||||
|
DESCRIPTOR.message_types_by_name['Empty'] = _EMPTY |
||||||
|
|
||||||
|
Empty = _reflection.GeneratedProtocolMessageType('Empty', (_message.Message,), dict( |
||||||
|
DESCRIPTOR = _EMPTY, |
||||||
|
__module__ = 'test.cpp.interop.empty_pb2' |
||||||
|
# @@protoc_insertion_point(class_scope:grpc.testing.Empty) |
||||||
|
)) |
||||||
|
_sym_db.RegisterMessage(Empty) |
||||||
|
|
||||||
|
|
||||||
|
# @@protoc_insertion_point(module_scope) |
@ -0,0 +1,444 @@ |
|||||||
|
# Generated by the protocol buffer compiler. DO NOT EDIT! |
||||||
|
# source: test/cpp/interop/messages.proto |
||||||
|
|
||||||
|
import sys |
||||||
|
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) |
||||||
|
from google.protobuf.internal import enum_type_wrapper |
||||||
|
from google.protobuf import descriptor as _descriptor |
||||||
|
from google.protobuf import message as _message |
||||||
|
from google.protobuf import reflection as _reflection |
||||||
|
from google.protobuf import symbol_database as _symbol_database |
||||||
|
from google.protobuf import descriptor_pb2 |
||||||
|
# @@protoc_insertion_point(imports) |
||||||
|
|
||||||
|
_sym_db = _symbol_database.Default() |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTOR = _descriptor.FileDescriptor( |
||||||
|
name='test/cpp/interop/messages.proto', |
||||||
|
package='grpc.testing', |
||||||
|
serialized_pb=_b('\n\x1ftest/cpp/interop/messages.proto\x12\x0cgrpc.testing\"@\n\x07Payload\x12\'\n\x04type\x18\x01 \x01(\x0e\x32\x19.grpc.testing.PayloadType\x12\x0c\n\x04\x62ody\x18\x02 \x01(\x0c\"\xb1\x01\n\rSimpleRequest\x12\x30\n\rresponse_type\x18\x01 \x01(\x0e\x32\x19.grpc.testing.PayloadType\x12\x15\n\rresponse_size\x18\x02 \x01(\x05\x12&\n\x07payload\x18\x03 \x01(\x0b\x32\x15.grpc.testing.Payload\x12\x15\n\rfill_username\x18\x04 \x01(\x08\x12\x18\n\x10\x66ill_oauth_scope\x18\x05 \x01(\x08\"_\n\x0eSimpleResponse\x12&\n\x07payload\x18\x01 \x01(\x0b\x32\x15.grpc.testing.Payload\x12\x10\n\x08username\x18\x02 \x01(\t\x12\x13\n\x0boauth_scope\x18\x03 \x01(\t\"C\n\x19StreamingInputCallRequest\x12&\n\x07payload\x18\x01 \x01(\x0b\x32\x15.grpc.testing.Payload\"=\n\x1aStreamingInputCallResponse\x12\x1f\n\x17\x61ggregated_payload_size\x18\x01 \x01(\x05\"7\n\x12ResponseParameters\x12\x0c\n\x04size\x18\x01 \x01(\x05\x12\x13\n\x0binterval_us\x18\x02 \x01(\x05\"\xb5\x01\n\x1aStreamingOutputCallRequest\x12\x30\n\rresponse_type\x18\x01 \x01(\x0e\x32\x19.grpc.testing.PayloadType\x12=\n\x13response_parameters\x18\x02 \x03(\x0b\x32 .grpc.testing.ResponseParameters\x12&\n\x07payload\x18\x03 \x01(\x0b\x32\x15.grpc.testing.Payload\"E\n\x1bStreamingOutputCallResponse\x12&\n\x07payload\x18\x01 \x01(\x0b\x32\x15.grpc.testing.Payload*?\n\x0bPayloadType\x12\x10\n\x0c\x43OMPRESSABLE\x10\x00\x12\x12\n\x0eUNCOMPRESSABLE\x10\x01\x12\n\n\x06RANDOM\x10\x02') |
||||||
|
) |
||||||
|
_sym_db.RegisterFileDescriptor(DESCRIPTOR) |
||||||
|
|
||||||
|
_PAYLOADTYPE = _descriptor.EnumDescriptor( |
||||||
|
name='PayloadType', |
||||||
|
full_name='grpc.testing.PayloadType', |
||||||
|
filename=None, |
||||||
|
file=DESCRIPTOR, |
||||||
|
values=[ |
||||||
|
_descriptor.EnumValueDescriptor( |
||||||
|
name='COMPRESSABLE', index=0, number=0, |
||||||
|
options=None, |
||||||
|
type=None), |
||||||
|
_descriptor.EnumValueDescriptor( |
||||||
|
name='UNCOMPRESSABLE', index=1, number=1, |
||||||
|
options=None, |
||||||
|
type=None), |
||||||
|
_descriptor.EnumValueDescriptor( |
||||||
|
name='RANDOM', index=2, number=2, |
||||||
|
options=None, |
||||||
|
type=None), |
||||||
|
], |
||||||
|
containing_type=None, |
||||||
|
options=None, |
||||||
|
serialized_start=836, |
||||||
|
serialized_end=899, |
||||||
|
) |
||||||
|
_sym_db.RegisterEnumDescriptor(_PAYLOADTYPE) |
||||||
|
|
||||||
|
PayloadType = enum_type_wrapper.EnumTypeWrapper(_PAYLOADTYPE) |
||||||
|
COMPRESSABLE = 0 |
||||||
|
UNCOMPRESSABLE = 1 |
||||||
|
RANDOM = 2 |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_PAYLOAD = _descriptor.Descriptor( |
||||||
|
name='Payload', |
||||||
|
full_name='grpc.testing.Payload', |
||||||
|
filename=None, |
||||||
|
file=DESCRIPTOR, |
||||||
|
containing_type=None, |
||||||
|
fields=[ |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='type', full_name='grpc.testing.Payload.type', index=0, |
||||||
|
number=1, type=14, cpp_type=8, label=1, |
||||||
|
has_default_value=False, default_value=0, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='body', full_name='grpc.testing.Payload.body', index=1, |
||||||
|
number=2, type=12, cpp_type=9, label=1, |
||||||
|
has_default_value=False, default_value=_b(""), |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
], |
||||||
|
extensions=[ |
||||||
|
], |
||||||
|
nested_types=[], |
||||||
|
enum_types=[ |
||||||
|
], |
||||||
|
options=None, |
||||||
|
is_extendable=False, |
||||||
|
extension_ranges=[], |
||||||
|
oneofs=[ |
||||||
|
], |
||||||
|
serialized_start=49, |
||||||
|
serialized_end=113, |
||||||
|
) |
||||||
|
|
||||||
|
|
||||||
|
_SIMPLEREQUEST = _descriptor.Descriptor( |
||||||
|
name='SimpleRequest', |
||||||
|
full_name='grpc.testing.SimpleRequest', |
||||||
|
filename=None, |
||||||
|
file=DESCRIPTOR, |
||||||
|
containing_type=None, |
||||||
|
fields=[ |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='response_type', full_name='grpc.testing.SimpleRequest.response_type', index=0, |
||||||
|
number=1, type=14, cpp_type=8, label=1, |
||||||
|
has_default_value=False, default_value=0, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='response_size', full_name='grpc.testing.SimpleRequest.response_size', index=1, |
||||||
|
number=2, type=5, cpp_type=1, label=1, |
||||||
|
has_default_value=False, default_value=0, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='payload', full_name='grpc.testing.SimpleRequest.payload', index=2, |
||||||
|
number=3, type=11, cpp_type=10, label=1, |
||||||
|
has_default_value=False, default_value=None, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='fill_username', full_name='grpc.testing.SimpleRequest.fill_username', index=3, |
||||||
|
number=4, type=8, cpp_type=7, label=1, |
||||||
|
has_default_value=False, default_value=False, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='fill_oauth_scope', full_name='grpc.testing.SimpleRequest.fill_oauth_scope', index=4, |
||||||
|
number=5, type=8, cpp_type=7, label=1, |
||||||
|
has_default_value=False, default_value=False, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
], |
||||||
|
extensions=[ |
||||||
|
], |
||||||
|
nested_types=[], |
||||||
|
enum_types=[ |
||||||
|
], |
||||||
|
options=None, |
||||||
|
is_extendable=False, |
||||||
|
extension_ranges=[], |
||||||
|
oneofs=[ |
||||||
|
], |
||||||
|
serialized_start=116, |
||||||
|
serialized_end=293, |
||||||
|
) |
||||||
|
|
||||||
|
|
||||||
|
_SIMPLERESPONSE = _descriptor.Descriptor( |
||||||
|
name='SimpleResponse', |
||||||
|
full_name='grpc.testing.SimpleResponse', |
||||||
|
filename=None, |
||||||
|
file=DESCRIPTOR, |
||||||
|
containing_type=None, |
||||||
|
fields=[ |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='payload', full_name='grpc.testing.SimpleResponse.payload', index=0, |
||||||
|
number=1, type=11, cpp_type=10, label=1, |
||||||
|
has_default_value=False, default_value=None, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='username', full_name='grpc.testing.SimpleResponse.username', index=1, |
||||||
|
number=2, type=9, cpp_type=9, label=1, |
||||||
|
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='oauth_scope', full_name='grpc.testing.SimpleResponse.oauth_scope', index=2, |
||||||
|
number=3, type=9, cpp_type=9, label=1, |
||||||
|
has_default_value=False, default_value=_b("").decode('utf-8'), |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
], |
||||||
|
extensions=[ |
||||||
|
], |
||||||
|
nested_types=[], |
||||||
|
enum_types=[ |
||||||
|
], |
||||||
|
options=None, |
||||||
|
is_extendable=False, |
||||||
|
extension_ranges=[], |
||||||
|
oneofs=[ |
||||||
|
], |
||||||
|
serialized_start=295, |
||||||
|
serialized_end=390, |
||||||
|
) |
||||||
|
|
||||||
|
|
||||||
|
_STREAMINGINPUTCALLREQUEST = _descriptor.Descriptor( |
||||||
|
name='StreamingInputCallRequest', |
||||||
|
full_name='grpc.testing.StreamingInputCallRequest', |
||||||
|
filename=None, |
||||||
|
file=DESCRIPTOR, |
||||||
|
containing_type=None, |
||||||
|
fields=[ |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='payload', full_name='grpc.testing.StreamingInputCallRequest.payload', index=0, |
||||||
|
number=1, type=11, cpp_type=10, label=1, |
||||||
|
has_default_value=False, default_value=None, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
], |
||||||
|
extensions=[ |
||||||
|
], |
||||||
|
nested_types=[], |
||||||
|
enum_types=[ |
||||||
|
], |
||||||
|
options=None, |
||||||
|
is_extendable=False, |
||||||
|
extension_ranges=[], |
||||||
|
oneofs=[ |
||||||
|
], |
||||||
|
serialized_start=392, |
||||||
|
serialized_end=459, |
||||||
|
) |
||||||
|
|
||||||
|
|
||||||
|
_STREAMINGINPUTCALLRESPONSE = _descriptor.Descriptor( |
||||||
|
name='StreamingInputCallResponse', |
||||||
|
full_name='grpc.testing.StreamingInputCallResponse', |
||||||
|
filename=None, |
||||||
|
file=DESCRIPTOR, |
||||||
|
containing_type=None, |
||||||
|
fields=[ |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='aggregated_payload_size', full_name='grpc.testing.StreamingInputCallResponse.aggregated_payload_size', index=0, |
||||||
|
number=1, type=5, cpp_type=1, label=1, |
||||||
|
has_default_value=False, default_value=0, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
], |
||||||
|
extensions=[ |
||||||
|
], |
||||||
|
nested_types=[], |
||||||
|
enum_types=[ |
||||||
|
], |
||||||
|
options=None, |
||||||
|
is_extendable=False, |
||||||
|
extension_ranges=[], |
||||||
|
oneofs=[ |
||||||
|
], |
||||||
|
serialized_start=461, |
||||||
|
serialized_end=522, |
||||||
|
) |
||||||
|
|
||||||
|
|
||||||
|
_RESPONSEPARAMETERS = _descriptor.Descriptor( |
||||||
|
name='ResponseParameters', |
||||||
|
full_name='grpc.testing.ResponseParameters', |
||||||
|
filename=None, |
||||||
|
file=DESCRIPTOR, |
||||||
|
containing_type=None, |
||||||
|
fields=[ |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='size', full_name='grpc.testing.ResponseParameters.size', index=0, |
||||||
|
number=1, type=5, cpp_type=1, label=1, |
||||||
|
has_default_value=False, default_value=0, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='interval_us', full_name='grpc.testing.ResponseParameters.interval_us', index=1, |
||||||
|
number=2, type=5, cpp_type=1, label=1, |
||||||
|
has_default_value=False, default_value=0, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
], |
||||||
|
extensions=[ |
||||||
|
], |
||||||
|
nested_types=[], |
||||||
|
enum_types=[ |
||||||
|
], |
||||||
|
options=None, |
||||||
|
is_extendable=False, |
||||||
|
extension_ranges=[], |
||||||
|
oneofs=[ |
||||||
|
], |
||||||
|
serialized_start=524, |
||||||
|
serialized_end=579, |
||||||
|
) |
||||||
|
|
||||||
|
|
||||||
|
_STREAMINGOUTPUTCALLREQUEST = _descriptor.Descriptor( |
||||||
|
name='StreamingOutputCallRequest', |
||||||
|
full_name='grpc.testing.StreamingOutputCallRequest', |
||||||
|
filename=None, |
||||||
|
file=DESCRIPTOR, |
||||||
|
containing_type=None, |
||||||
|
fields=[ |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='response_type', full_name='grpc.testing.StreamingOutputCallRequest.response_type', index=0, |
||||||
|
number=1, type=14, cpp_type=8, label=1, |
||||||
|
has_default_value=False, default_value=0, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='response_parameters', full_name='grpc.testing.StreamingOutputCallRequest.response_parameters', index=1, |
||||||
|
number=2, type=11, cpp_type=10, label=3, |
||||||
|
has_default_value=False, default_value=[], |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='payload', full_name='grpc.testing.StreamingOutputCallRequest.payload', index=2, |
||||||
|
number=3, type=11, cpp_type=10, label=1, |
||||||
|
has_default_value=False, default_value=None, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
], |
||||||
|
extensions=[ |
||||||
|
], |
||||||
|
nested_types=[], |
||||||
|
enum_types=[ |
||||||
|
], |
||||||
|
options=None, |
||||||
|
is_extendable=False, |
||||||
|
extension_ranges=[], |
||||||
|
oneofs=[ |
||||||
|
], |
||||||
|
serialized_start=582, |
||||||
|
serialized_end=763, |
||||||
|
) |
||||||
|
|
||||||
|
|
||||||
|
_STREAMINGOUTPUTCALLRESPONSE = _descriptor.Descriptor( |
||||||
|
name='StreamingOutputCallResponse', |
||||||
|
full_name='grpc.testing.StreamingOutputCallResponse', |
||||||
|
filename=None, |
||||||
|
file=DESCRIPTOR, |
||||||
|
containing_type=None, |
||||||
|
fields=[ |
||||||
|
_descriptor.FieldDescriptor( |
||||||
|
name='payload', full_name='grpc.testing.StreamingOutputCallResponse.payload', index=0, |
||||||
|
number=1, type=11, cpp_type=10, label=1, |
||||||
|
has_default_value=False, default_value=None, |
||||||
|
message_type=None, enum_type=None, containing_type=None, |
||||||
|
is_extension=False, extension_scope=None, |
||||||
|
options=None), |
||||||
|
], |
||||||
|
extensions=[ |
||||||
|
], |
||||||
|
nested_types=[], |
||||||
|
enum_types=[ |
||||||
|
], |
||||||
|
options=None, |
||||||
|
is_extendable=False, |
||||||
|
extension_ranges=[], |
||||||
|
oneofs=[ |
||||||
|
], |
||||||
|
serialized_start=765, |
||||||
|
serialized_end=834, |
||||||
|
) |
||||||
|
|
||||||
|
_PAYLOAD.fields_by_name['type'].enum_type = _PAYLOADTYPE |
||||||
|
_SIMPLEREQUEST.fields_by_name['response_type'].enum_type = _PAYLOADTYPE |
||||||
|
_SIMPLEREQUEST.fields_by_name['payload'].message_type = _PAYLOAD |
||||||
|
_SIMPLERESPONSE.fields_by_name['payload'].message_type = _PAYLOAD |
||||||
|
_STREAMINGINPUTCALLREQUEST.fields_by_name['payload'].message_type = _PAYLOAD |
||||||
|
_STREAMINGOUTPUTCALLREQUEST.fields_by_name['response_type'].enum_type = _PAYLOADTYPE |
||||||
|
_STREAMINGOUTPUTCALLREQUEST.fields_by_name['response_parameters'].message_type = _RESPONSEPARAMETERS |
||||||
|
_STREAMINGOUTPUTCALLREQUEST.fields_by_name['payload'].message_type = _PAYLOAD |
||||||
|
_STREAMINGOUTPUTCALLRESPONSE.fields_by_name['payload'].message_type = _PAYLOAD |
||||||
|
DESCRIPTOR.message_types_by_name['Payload'] = _PAYLOAD |
||||||
|
DESCRIPTOR.message_types_by_name['SimpleRequest'] = _SIMPLEREQUEST |
||||||
|
DESCRIPTOR.message_types_by_name['SimpleResponse'] = _SIMPLERESPONSE |
||||||
|
DESCRIPTOR.message_types_by_name['StreamingInputCallRequest'] = _STREAMINGINPUTCALLREQUEST |
||||||
|
DESCRIPTOR.message_types_by_name['StreamingInputCallResponse'] = _STREAMINGINPUTCALLRESPONSE |
||||||
|
DESCRIPTOR.message_types_by_name['ResponseParameters'] = _RESPONSEPARAMETERS |
||||||
|
DESCRIPTOR.message_types_by_name['StreamingOutputCallRequest'] = _STREAMINGOUTPUTCALLREQUEST |
||||||
|
DESCRIPTOR.message_types_by_name['StreamingOutputCallResponse'] = _STREAMINGOUTPUTCALLRESPONSE |
||||||
|
DESCRIPTOR.enum_types_by_name['PayloadType'] = _PAYLOADTYPE |
||||||
|
|
||||||
|
Payload = _reflection.GeneratedProtocolMessageType('Payload', (_message.Message,), dict( |
||||||
|
DESCRIPTOR = _PAYLOAD, |
||||||
|
__module__ = 'test.cpp.interop.messages_pb2' |
||||||
|
# @@protoc_insertion_point(class_scope:grpc.testing.Payload) |
||||||
|
)) |
||||||
|
_sym_db.RegisterMessage(Payload) |
||||||
|
|
||||||
|
SimpleRequest = _reflection.GeneratedProtocolMessageType('SimpleRequest', (_message.Message,), dict( |
||||||
|
DESCRIPTOR = _SIMPLEREQUEST, |
||||||
|
__module__ = 'test.cpp.interop.messages_pb2' |
||||||
|
# @@protoc_insertion_point(class_scope:grpc.testing.SimpleRequest) |
||||||
|
)) |
||||||
|
_sym_db.RegisterMessage(SimpleRequest) |
||||||
|
|
||||||
|
SimpleResponse = _reflection.GeneratedProtocolMessageType('SimpleResponse', (_message.Message,), dict( |
||||||
|
DESCRIPTOR = _SIMPLERESPONSE, |
||||||
|
__module__ = 'test.cpp.interop.messages_pb2' |
||||||
|
# @@protoc_insertion_point(class_scope:grpc.testing.SimpleResponse) |
||||||
|
)) |
||||||
|
_sym_db.RegisterMessage(SimpleResponse) |
||||||
|
|
||||||
|
StreamingInputCallRequest = _reflection.GeneratedProtocolMessageType('StreamingInputCallRequest', (_message.Message,), dict( |
||||||
|
DESCRIPTOR = _STREAMINGINPUTCALLREQUEST, |
||||||
|
__module__ = 'test.cpp.interop.messages_pb2' |
||||||
|
# @@protoc_insertion_point(class_scope:grpc.testing.StreamingInputCallRequest) |
||||||
|
)) |
||||||
|
_sym_db.RegisterMessage(StreamingInputCallRequest) |
||||||
|
|
||||||
|
StreamingInputCallResponse = _reflection.GeneratedProtocolMessageType('StreamingInputCallResponse', (_message.Message,), dict( |
||||||
|
DESCRIPTOR = _STREAMINGINPUTCALLRESPONSE, |
||||||
|
__module__ = 'test.cpp.interop.messages_pb2' |
||||||
|
# @@protoc_insertion_point(class_scope:grpc.testing.StreamingInputCallResponse) |
||||||
|
)) |
||||||
|
_sym_db.RegisterMessage(StreamingInputCallResponse) |
||||||
|
|
||||||
|
ResponseParameters = _reflection.GeneratedProtocolMessageType('ResponseParameters', (_message.Message,), dict( |
||||||
|
DESCRIPTOR = _RESPONSEPARAMETERS, |
||||||
|
__module__ = 'test.cpp.interop.messages_pb2' |
||||||
|
# @@protoc_insertion_point(class_scope:grpc.testing.ResponseParameters) |
||||||
|
)) |
||||||
|
_sym_db.RegisterMessage(ResponseParameters) |
||||||
|
|
||||||
|
StreamingOutputCallRequest = _reflection.GeneratedProtocolMessageType('StreamingOutputCallRequest', (_message.Message,), dict( |
||||||
|
DESCRIPTOR = _STREAMINGOUTPUTCALLREQUEST, |
||||||
|
__module__ = 'test.cpp.interop.messages_pb2' |
||||||
|
# @@protoc_insertion_point(class_scope:grpc.testing.StreamingOutputCallRequest) |
||||||
|
)) |
||||||
|
_sym_db.RegisterMessage(StreamingOutputCallRequest) |
||||||
|
|
||||||
|
StreamingOutputCallResponse = _reflection.GeneratedProtocolMessageType('StreamingOutputCallResponse', (_message.Message,), dict( |
||||||
|
DESCRIPTOR = _STREAMINGOUTPUTCALLRESPONSE, |
||||||
|
__module__ = 'test.cpp.interop.messages_pb2' |
||||||
|
# @@protoc_insertion_point(class_scope:grpc.testing.StreamingOutputCallResponse) |
||||||
|
)) |
||||||
|
_sym_db.RegisterMessage(StreamingOutputCallResponse) |
||||||
|
|
||||||
|
|
||||||
|
# @@protoc_insertion_point(module_scope) |
@ -0,0 +1,109 @@ |
|||||||
|
# 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. |
||||||
|
|
||||||
|
"""Implementations of interoperability test methods.""" |
||||||
|
|
||||||
|
from grpc.early_adopter import utilities |
||||||
|
|
||||||
|
from interop import empty_pb2 |
||||||
|
from interop import messages_pb2 |
||||||
|
|
||||||
|
def _empty_call(request): |
||||||
|
return empty_pb2.Empty() |
||||||
|
|
||||||
|
EMPTY_CALL = utilities.unary_unary_rpc_method( |
||||||
|
_empty_call, empty_pb2.Empty.SerializeToString, empty_pb2.Empty.FromString, |
||||||
|
empty_pb2.Empty.SerializeToString, empty_pb2.Empty.FromString) |
||||||
|
|
||||||
|
|
||||||
|
def _unary_call(request): |
||||||
|
return messages_pb2.SimpleResponse( |
||||||
|
payload=messages_pb2.Payload( |
||||||
|
type=messages_pb2.COMPRESSABLE, |
||||||
|
body=b'\x00' * request.response_size)) |
||||||
|
|
||||||
|
UNARY_CALL = utilities.unary_unary_rpc_method( |
||||||
|
_unary_call, messages_pb2.SimpleRequest.SerializeToString, |
||||||
|
messages_pb2.SimpleRequest.FromString, |
||||||
|
messages_pb2.SimpleResponse.SerializeToString, |
||||||
|
messages_pb2.SimpleResponse.FromString) |
||||||
|
|
||||||
|
|
||||||
|
def _streaming_output_call(request): |
||||||
|
for response_parameters in request.response_parameters: |
||||||
|
yield messages_pb2.StreamingOutputCallResponse( |
||||||
|
payload=messages_pb2.Payload( |
||||||
|
type=request.response_type, |
||||||
|
body=b'\x00' * response_parameters.size)) |
||||||
|
|
||||||
|
STREAMING_OUTPUT_CALL = utilities.unary_stream_rpc_method( |
||||||
|
_streaming_output_call, |
||||||
|
messages_pb2.StreamingOutputCallRequest.SerializeToString, |
||||||
|
messages_pb2.StreamingOutputCallRequest.FromString, |
||||||
|
messages_pb2.StreamingOutputCallResponse.SerializeToString, |
||||||
|
messages_pb2.StreamingOutputCallResponse.FromString) |
||||||
|
|
||||||
|
|
||||||
|
def _streaming_input_call(request_iterator): |
||||||
|
aggregate_size = 0 |
||||||
|
for request in request_iterator: |
||||||
|
if request.payload and request.payload.body: |
||||||
|
aggregate_size += len(request.payload.body) |
||||||
|
return messages_pb2.StreamingInputCallResponse( |
||||||
|
aggregated_payload_size=aggregate_size) |
||||||
|
|
||||||
|
STREAMING_INPUT_CALL = utilities.stream_unary_rpc_method( |
||||||
|
_streaming_input_call, |
||||||
|
messages_pb2.StreamingInputCallRequest.SerializeToString, |
||||||
|
messages_pb2.StreamingInputCallRequest.FromString, |
||||||
|
messages_pb2.StreamingInputCallResponse.SerializeToString, |
||||||
|
messages_pb2.StreamingInputCallResponse.FromString) |
||||||
|
|
||||||
|
|
||||||
|
def _full_duplex_call(request_iterator): |
||||||
|
for request in request_iterator: |
||||||
|
yield messages_pb2.StreamingOutputCallResponse( |
||||||
|
payload=messages_pb2.Payload( |
||||||
|
type=request.payload.type, |
||||||
|
body=b'\x00' * request.response_parameters[0].size)) |
||||||
|
|
||||||
|
FULL_DUPLEX_CALL = utilities.stream_stream_rpc_method( |
||||||
|
_full_duplex_call, |
||||||
|
messages_pb2.StreamingOutputCallRequest.SerializeToString, |
||||||
|
messages_pb2.StreamingOutputCallRequest.FromString, |
||||||
|
messages_pb2.StreamingOutputCallResponse.SerializeToString, |
||||||
|
messages_pb2.StreamingOutputCallResponse.FromString) |
||||||
|
|
||||||
|
# NOTE(nathaniel): Apparently this is the same as the full-duplex call? |
||||||
|
HALF_DUPLEX_CALL = utilities.stream_stream_rpc_method( |
||||||
|
_full_duplex_call, |
||||||
|
messages_pb2.StreamingOutputCallRequest.SerializeToString, |
||||||
|
messages_pb2.StreamingOutputCallRequest.FromString, |
||||||
|
messages_pb2.StreamingOutputCallResponse.SerializeToString, |
||||||
|
messages_pb2.StreamingOutputCallResponse.FromString) |
@ -0,0 +1,91 @@ |
|||||||
|
# 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. |
||||||
|
|
||||||
|
"""The Python implementation of the GRPC interoperability test server.""" |
||||||
|
|
||||||
|
import argparse |
||||||
|
import logging |
||||||
|
import pkg_resources |
||||||
|
import time |
||||||
|
|
||||||
|
from grpc.early_adopter import implementations |
||||||
|
|
||||||
|
from interop import methods |
||||||
|
|
||||||
|
_ONE_DAY_IN_SECONDS = 60 * 60 * 24 |
||||||
|
|
||||||
|
_PRIVATE_KEY_RESOURCE_PATH = 'credentials/server1.key' |
||||||
|
_CERTIFICATE_CHAIN_RESOURCE_PATH = 'credentials/server1.pem' |
||||||
|
|
||||||
|
_METHODS = { |
||||||
|
'/grpc.testing.TestService/EmptyCall': methods.EMPTY_CALL, |
||||||
|
'/grpc.testing.TestService/UnaryCall': methods.UNARY_CALL, |
||||||
|
'/grpc.testing.TestService/StreamingOutputCall': |
||||||
|
methods.STREAMING_OUTPUT_CALL, |
||||||
|
'/grpc.testing.TestService/StreamingInputCall': |
||||||
|
methods.STREAMING_INPUT_CALL, |
||||||
|
'/grpc.testing.TestService/FullDuplexCall': |
||||||
|
methods.FULL_DUPLEX_CALL, |
||||||
|
'/grpc.testing.TestService/HalfDuplexCall': |
||||||
|
methods.HALF_DUPLEX_CALL, |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
def serve(): |
||||||
|
parser = argparse.ArgumentParser() |
||||||
|
parser.add_argument( |
||||||
|
'--port', help='the port on which to serve', type=int) |
||||||
|
parser.add_argument( |
||||||
|
'--use_tls', help='require a secure connection', dest='use_tls', |
||||||
|
action='store_true') |
||||||
|
args = parser.parse_args() |
||||||
|
|
||||||
|
if args.use_tls: |
||||||
|
private_key = pkg_resources.resource_string( |
||||||
|
__name__, _PRIVATE_KEY_RESOURCE_PATH) |
||||||
|
certificate_chain = pkg_resources.resource_string( |
||||||
|
__name__, _CERTIFICATE_CHAIN_RESOURCE_PATH) |
||||||
|
server = implementations.secure_server( |
||||||
|
_METHODS, args.port, private_key, certificate_chain) |
||||||
|
else: |
||||||
|
server = implementations.insecure_server( |
||||||
|
_METHODS, args.port) |
||||||
|
|
||||||
|
server.start() |
||||||
|
logging.info('Server serving.') |
||||||
|
try: |
||||||
|
while True: |
||||||
|
time.sleep(_ONE_DAY_IN_SECONDS) |
||||||
|
except BaseException as e: |
||||||
|
logging.info('Caught exception "%s"; stopping server...', e) |
||||||
|
server.stop() |
||||||
|
logging.info('Server stopped; exiting.') |
||||||
|
|
||||||
|
if __name__ == '__main__': |
||||||
|
serve() |
@ -0,0 +1,32 @@ |
|||||||
|
# Generated by the protocol buffer compiler. DO NOT EDIT! |
||||||
|
# source: test/cpp/interop/test.proto |
||||||
|
|
||||||
|
import sys |
||||||
|
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) |
||||||
|
from google.protobuf import descriptor as _descriptor |
||||||
|
from google.protobuf import message as _message |
||||||
|
from google.protobuf import reflection as _reflection |
||||||
|
from google.protobuf import symbol_database as _symbol_database |
||||||
|
from google.protobuf import descriptor_pb2 |
||||||
|
# @@protoc_insertion_point(imports) |
||||||
|
|
||||||
|
_sym_db = _symbol_database.Default() |
||||||
|
|
||||||
|
|
||||||
|
from test.cpp.interop import empty_pb2 as test_dot_cpp_dot_interop_dot_empty__pb2 |
||||||
|
from test.cpp.interop import messages_pb2 as test_dot_cpp_dot_interop_dot_messages__pb2 |
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTOR = _descriptor.FileDescriptor( |
||||||
|
name='test/cpp/interop/test.proto', |
||||||
|
package='grpc.testing', |
||||||
|
serialized_pb=_b('\n\x1btest/cpp/interop/test.proto\x12\x0cgrpc.testing\x1a\x1ctest/cpp/interop/empty.proto\x1a\x1ftest/cpp/interop/messages.proto2\xbb\x04\n\x0bTestService\x12\x35\n\tEmptyCall\x12\x13.grpc.testing.Empty\x1a\x13.grpc.testing.Empty\x12\x46\n\tUnaryCall\x12\x1b.grpc.testing.SimpleRequest\x1a\x1c.grpc.testing.SimpleResponse\x12l\n\x13StreamingOutputCall\x12(.grpc.testing.StreamingOutputCallRequest\x1a).grpc.testing.StreamingOutputCallResponse0\x01\x12i\n\x12StreamingInputCall\x12\'.grpc.testing.StreamingInputCallRequest\x1a(.grpc.testing.StreamingInputCallResponse(\x01\x12i\n\x0e\x46ullDuplexCall\x12(.grpc.testing.StreamingOutputCallRequest\x1a).grpc.testing.StreamingOutputCallResponse(\x01\x30\x01\x12i\n\x0eHalfDuplexCall\x12(.grpc.testing.StreamingOutputCallRequest\x1a).grpc.testing.StreamingOutputCallResponse(\x01\x30\x01') |
||||||
|
, |
||||||
|
dependencies=[test_dot_cpp_dot_interop_dot_empty__pb2.DESCRIPTOR,test_dot_cpp_dot_interop_dot_messages__pb2.DESCRIPTOR,]) |
||||||
|
_sym_db.RegisterFileDescriptor(DESCRIPTOR) |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# @@protoc_insertion_point(module_scope) |
@ -1,30 +0,0 @@ |
|||||||
# Copyright 2015, Google Inc. |
|
||||||
# All rights reserved. |
|
||||||
# |
|
||||||
# Redistribution and use in source and binary forms, with or without |
|
||||||
# modification, are permitted provided that the following conditions are |
|
||||||
# met: |
|
||||||
# |
|
||||||
# * Redistributions of source code must retain the above copyright |
|
||||||
# notice, this list of conditions and the following disclaimer. |
|
||||||
# * Redistributions in binary form must reproduce the above |
|
||||||
# copyright notice, this list of conditions and the following disclaimer |
|
||||||
# in the documentation and/or other materials provided with the |
|
||||||
# distribution. |
|
||||||
# * Neither the name of Google Inc. nor the names of its |
|
||||||
# contributors may be used to endorse or promote products derived from |
|
||||||
# this software without specific prior written permission. |
|
||||||
# |
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
|
||||||
|
|
@ -1,30 +0,0 @@ |
|||||||
# Copyright 2015, Google Inc. |
|
||||||
# All rights reserved. |
|
||||||
# |
|
||||||
# Redistribution and use in source and binary forms, with or without |
|
||||||
# modification, are permitted provided that the following conditions are |
|
||||||
# met: |
|
||||||
# |
|
||||||
# * Redistributions of source code must retain the above copyright |
|
||||||
# notice, this list of conditions and the following disclaimer. |
|
||||||
# * Redistributions in binary form must reproduce the above |
|
||||||
# copyright notice, this list of conditions and the following disclaimer |
|
||||||
# in the documentation and/or other materials provided with the |
|
||||||
# distribution. |
|
||||||
# * Neither the name of Google Inc. nor the names of its |
|
||||||
# contributors may be used to endorse or promote products derived from |
|
||||||
# this software without specific prior written permission. |
|
||||||
# |
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
|
||||||
|
|
@ -1,30 +0,0 @@ |
|||||||
# Copyright 2015, Google Inc. |
|
||||||
# All rights reserved. |
|
||||||
# |
|
||||||
# Redistribution and use in source and binary forms, with or without |
|
||||||
# modification, are permitted provided that the following conditions are |
|
||||||
# met: |
|
||||||
# |
|
||||||
# * Redistributions of source code must retain the above copyright |
|
||||||
# notice, this list of conditions and the following disclaimer. |
|
||||||
# * Redistributions in binary form must reproduce the above |
|
||||||
# copyright notice, this list of conditions and the following disclaimer |
|
||||||
# in the documentation and/or other materials provided with the |
|
||||||
# distribution. |
|
||||||
# * Neither the name of Google Inc. nor the names of its |
|
||||||
# contributors may be used to endorse or promote products derived from |
|
||||||
# this software without specific prior written permission. |
|
||||||
# |
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
|
||||||
|
|
@ -1,30 +0,0 @@ |
|||||||
# Copyright 2015, Google Inc. |
|
||||||
# All rights reserved. |
|
||||||
# |
|
||||||
# Redistribution and use in source and binary forms, with or without |
|
||||||
# modification, are permitted provided that the following conditions are |
|
||||||
# met: |
|
||||||
# |
|
||||||
# * Redistributions of source code must retain the above copyright |
|
||||||
# notice, this list of conditions and the following disclaimer. |
|
||||||
# * Redistributions in binary form must reproduce the above |
|
||||||
# copyright notice, this list of conditions and the following disclaimer |
|
||||||
# in the documentation and/or other materials provided with the |
|
||||||
# distribution. |
|
||||||
# * Neither the name of Google Inc. nor the names of its |
|
||||||
# contributors may be used to endorse or promote products derived from |
|
||||||
# this software without specific prior written permission. |
|
||||||
# |
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
|
||||||
|
|
@ -1,30 +0,0 @@ |
|||||||
# Copyright 2015, Google Inc. |
|
||||||
# All rights reserved. |
|
||||||
# |
|
||||||
# Redistribution and use in source and binary forms, with or without |
|
||||||
# modification, are permitted provided that the following conditions are |
|
||||||
# met: |
|
||||||
# |
|
||||||
# * Redistributions of source code must retain the above copyright |
|
||||||
# notice, this list of conditions and the following disclaimer. |
|
||||||
# * Redistributions in binary form must reproduce the above |
|
||||||
# copyright notice, this list of conditions and the following disclaimer |
|
||||||
# in the documentation and/or other materials provided with the |
|
||||||
# distribution. |
|
||||||
# * Neither the name of Google Inc. nor the names of its |
|
||||||
# contributors may be used to endorse or promote products derived from |
|
||||||
# this software without specific prior written permission. |
|
||||||
# |
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
|
||||||
|
|
@ -1,30 +0,0 @@ |
|||||||
# Copyright 2015, Google Inc. |
|
||||||
# All rights reserved. |
|
||||||
# |
|
||||||
# Redistribution and use in source and binary forms, with or without |
|
||||||
# modification, are permitted provided that the following conditions are |
|
||||||
# met: |
|
||||||
# |
|
||||||
# * Redistributions of source code must retain the above copyright |
|
||||||
# notice, this list of conditions and the following disclaimer. |
|
||||||
# * Redistributions in binary form must reproduce the above |
|
||||||
# copyright notice, this list of conditions and the following disclaimer |
|
||||||
# in the documentation and/or other materials provided with the |
|
||||||
# distribution. |
|
||||||
# * Neither the name of Google Inc. nor the names of its |
|
||||||
# contributors may be used to endorse or promote products derived from |
|
||||||
# this software without specific prior written permission. |
|
||||||
# |
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
|
||||||
|
|
@ -1,30 +0,0 @@ |
|||||||
# Copyright 2015, Google Inc. |
|
||||||
# All rights reserved. |
|
||||||
# |
|
||||||
# Redistribution and use in source and binary forms, with or without |
|
||||||
# modification, are permitted provided that the following conditions are |
|
||||||
# met: |
|
||||||
# |
|
||||||
# * Redistributions of source code must retain the above copyright |
|
||||||
# notice, this list of conditions and the following disclaimer. |
|
||||||
# * Redistributions in binary form must reproduce the above |
|
||||||
# copyright notice, this list of conditions and the following disclaimer |
|
||||||
# in the documentation and/or other materials provided with the |
|
||||||
# distribution. |
|
||||||
# * Neither the name of Google Inc. nor the names of its |
|
||||||
# contributors may be used to endorse or promote products derived from |
|
||||||
# this software without specific prior written permission. |
|
||||||
# |
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
|
||||||
|
|
@ -1,30 +0,0 @@ |
|||||||
# Copyright 2015, Google Inc. |
|
||||||
# All rights reserved. |
|
||||||
# |
|
||||||
# Redistribution and use in source and binary forms, with or without |
|
||||||
# modification, are permitted provided that the following conditions are |
|
||||||
# met: |
|
||||||
# |
|
||||||
# * Redistributions of source code must retain the above copyright |
|
||||||
# notice, this list of conditions and the following disclaimer. |
|
||||||
# * Redistributions in binary form must reproduce the above |
|
||||||
# copyright notice, this list of conditions and the following disclaimer |
|
||||||
# in the documentation and/or other materials provided with the |
|
||||||
# distribution. |
|
||||||
# * Neither the name of Google Inc. nor the names of its |
|
||||||
# contributors may be used to endorse or promote products derived from |
|
||||||
# this software without specific prior written permission. |
|
||||||
# |
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
|
||||||
|
|
@ -1,30 +0,0 @@ |
|||||||
# Copyright 2015, Google Inc. |
|
||||||
# All rights reserved. |
|
||||||
# |
|
||||||
# Redistribution and use in source and binary forms, with or without |
|
||||||
# modification, are permitted provided that the following conditions are |
|
||||||
# met: |
|
||||||
# |
|
||||||
# * Redistributions of source code must retain the above copyright |
|
||||||
# notice, this list of conditions and the following disclaimer. |
|
||||||
# * Redistributions in binary form must reproduce the above |
|
||||||
# copyright notice, this list of conditions and the following disclaimer |
|
||||||
# in the documentation and/or other materials provided with the |
|
||||||
# distribution. |
|
||||||
# * Neither the name of Google Inc. nor the names of its |
|
||||||
# contributors may be used to endorse or promote products derived from |
|
||||||
# this software without specific prior written permission. |
|
||||||
# |
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
||||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
||||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
||||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
||||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
||||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
||||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
||||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
||||||
|
|
||||||
|
|
@ -0,0 +1,143 @@ |
|||||||
|
# Copyright 2015, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
import abc |
||||||
|
import collections |
||||||
|
|
||||||
|
from grpc.framework.face import interfaces as face_interfaces |
||||||
|
|
||||||
|
from grpc.early_adopter import interfaces |
||||||
|
|
||||||
|
|
||||||
|
class _InlineUnaryUnaryMethod(face_interfaces.InlineValueInValueOutMethod): |
||||||
|
|
||||||
|
def __init__(self, unary_unary_rpc_method): |
||||||
|
self._method = unary_unary_rpc_method |
||||||
|
|
||||||
|
def service(self, request, context): |
||||||
|
"""See face_interfaces.InlineValueInValueOutMethod.service for spec.""" |
||||||
|
return self._method.service_unary_unary(request) |
||||||
|
|
||||||
|
|
||||||
|
class _InlineUnaryStreamMethod(face_interfaces.InlineValueInStreamOutMethod): |
||||||
|
|
||||||
|
def __init__(self, unary_stream_rpc_method): |
||||||
|
self._method = unary_stream_rpc_method |
||||||
|
|
||||||
|
def service(self, request, context): |
||||||
|
"""See face_interfaces.InlineValueInStreamOutMethod.service for spec.""" |
||||||
|
return self._method.service_unary_stream(request) |
||||||
|
|
||||||
|
|
||||||
|
class _InlineStreamUnaryMethod(face_interfaces.InlineStreamInValueOutMethod): |
||||||
|
|
||||||
|
def __init__(self, stream_unary_rpc_method): |
||||||
|
self._method = stream_unary_rpc_method |
||||||
|
|
||||||
|
def service(self, request_iterator, context): |
||||||
|
"""See face_interfaces.InlineStreamInValueOutMethod.service for spec.""" |
||||||
|
return self._method.service_stream_unary(request_iterator) |
||||||
|
|
||||||
|
|
||||||
|
class _InlineStreamStreamMethod(face_interfaces.InlineStreamInStreamOutMethod): |
||||||
|
|
||||||
|
def __init__(self, stream_stream_rpc_method): |
||||||
|
self._method = stream_stream_rpc_method |
||||||
|
|
||||||
|
def service(self, request_iterator, context): |
||||||
|
"""See face_interfaces.InlineStreamInStreamOutMethod.service for spec.""" |
||||||
|
return self._method.service_stream_stream(request_iterator) |
||||||
|
|
||||||
|
|
||||||
|
class Breakdown(object): |
||||||
|
"""An intermediate representation of implementations of RPC methods. |
||||||
|
|
||||||
|
Attributes: |
||||||
|
unary_unary_methods: |
||||||
|
unary_stream_methods: |
||||||
|
stream_unary_methods: |
||||||
|
stream_stream_methods: |
||||||
|
request_serializers: |
||||||
|
request_deserializers: |
||||||
|
response_serializers: |
||||||
|
response_deserializers: |
||||||
|
""" |
||||||
|
__metaclass__ = abc.ABCMeta |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class _EasyBreakdown( |
||||||
|
Breakdown, |
||||||
|
collections.namedtuple( |
||||||
|
'_EasyBreakdown', |
||||||
|
['unary_unary_methods', 'unary_stream_methods', 'stream_unary_methods', |
||||||
|
'stream_stream_methods', 'request_serializers', |
||||||
|
'request_deserializers', 'response_serializers', |
||||||
|
'response_deserializers'])): |
||||||
|
pass |
||||||
|
|
||||||
|
|
||||||
|
def break_down(methods): |
||||||
|
"""Breaks down RPC methods. |
||||||
|
|
||||||
|
Args: |
||||||
|
methods: A dictionary from RPC mthod name to |
||||||
|
interfaces.RpcMethod object describing the RPCs. |
||||||
|
|
||||||
|
Returns: |
||||||
|
A Breakdown corresponding to the given methods. |
||||||
|
""" |
||||||
|
unary_unary = {} |
||||||
|
unary_stream = {} |
||||||
|
stream_unary = {} |
||||||
|
stream_stream = {} |
||||||
|
request_serializers = {} |
||||||
|
request_deserializers = {} |
||||||
|
response_serializers = {} |
||||||
|
response_deserializers = {} |
||||||
|
|
||||||
|
for name, method in methods.iteritems(): |
||||||
|
cardinality = method.cardinality() |
||||||
|
if cardinality is interfaces.Cardinality.UNARY_UNARY: |
||||||
|
unary_unary[name] = _InlineUnaryUnaryMethod(method) |
||||||
|
elif cardinality is interfaces.Cardinality.UNARY_STREAM: |
||||||
|
unary_stream[name] = _InlineUnaryStreamMethod(method) |
||||||
|
elif cardinality is interfaces.Cardinality.STREAM_UNARY: |
||||||
|
stream_unary[name] = _InlineStreamUnaryMethod(method) |
||||||
|
elif cardinality is interfaces.Cardinality.STREAM_STREAM: |
||||||
|
stream_stream[name] = _InlineStreamStreamMethod(method) |
||||||
|
request_serializers[name] = method.serialize_request |
||||||
|
request_deserializers[name] = method.deserialize_request |
||||||
|
response_serializers[name] = method.serialize_response |
||||||
|
response_deserializers[name] = method.deserialize_response |
||||||
|
|
||||||
|
return _EasyBreakdown( |
||||||
|
unary_unary, unary_stream, stream_unary, stream_stream, |
||||||
|
request_serializers, request_deserializers, response_serializers, |
||||||
|
response_deserializers) |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue