mirror of https://github.com/grpc/grpc.git
commit
41fd9f2343
94 changed files with 3458 additions and 843 deletions
@ -0,0 +1,181 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#include <grpc++/impl/sync.h> |
||||||
|
#include <grpc++/impl/thd.h> |
||||||
|
#include <grpc/support/log.h> |
||||||
|
#include <climits> |
||||||
|
|
||||||
|
#include "src/cpp/thread_manager/thread_manager.h" |
||||||
|
|
||||||
|
namespace grpc { |
||||||
|
|
||||||
|
ThreadManager::WorkerThread::WorkerThread(ThreadManager* thd_mgr) |
||||||
|
: thd_mgr_(thd_mgr), thd_(&ThreadManager::WorkerThread::Run, this) {} |
||||||
|
|
||||||
|
void ThreadManager::WorkerThread::Run() { |
||||||
|
thd_mgr_->MainWorkLoop(); |
||||||
|
thd_mgr_->MarkAsCompleted(this); |
||||||
|
} |
||||||
|
|
||||||
|
ThreadManager::WorkerThread::~WorkerThread() { thd_.join(); } |
||||||
|
|
||||||
|
ThreadManager::ThreadManager(int min_pollers, int max_pollers) |
||||||
|
: shutdown_(false), |
||||||
|
num_pollers_(0), |
||||||
|
min_pollers_(min_pollers), |
||||||
|
max_pollers_(max_pollers == -1 ? INT_MAX : max_pollers), |
||||||
|
num_threads_(0) {} |
||||||
|
|
||||||
|
ThreadManager::~ThreadManager() { |
||||||
|
{ |
||||||
|
std::unique_lock<grpc::mutex> lock(mu_); |
||||||
|
GPR_ASSERT(num_threads_ == 0); |
||||||
|
} |
||||||
|
|
||||||
|
CleanupCompletedThreads(); |
||||||
|
} |
||||||
|
|
||||||
|
void ThreadManager::Wait() { |
||||||
|
std::unique_lock<grpc::mutex> lock(mu_); |
||||||
|
while (num_threads_ != 0) { |
||||||
|
shutdown_cv_.wait(lock); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void ThreadManager::Shutdown() { |
||||||
|
std::unique_lock<grpc::mutex> lock(mu_); |
||||||
|
shutdown_ = true; |
||||||
|
} |
||||||
|
|
||||||
|
bool ThreadManager::IsShutdown() { |
||||||
|
std::unique_lock<grpc::mutex> lock(mu_); |
||||||
|
return shutdown_; |
||||||
|
} |
||||||
|
|
||||||
|
void ThreadManager::MarkAsCompleted(WorkerThread* thd) { |
||||||
|
{ |
||||||
|
std::unique_lock<grpc::mutex> list_lock(list_mu_); |
||||||
|
completed_threads_.push_back(thd); |
||||||
|
} |
||||||
|
|
||||||
|
grpc::unique_lock<grpc::mutex> lock(mu_); |
||||||
|
num_threads_--; |
||||||
|
if (num_threads_ == 0) { |
||||||
|
shutdown_cv_.notify_one(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void ThreadManager::CleanupCompletedThreads() { |
||||||
|
std::unique_lock<grpc::mutex> lock(list_mu_); |
||||||
|
for (auto thd = completed_threads_.begin(); thd != completed_threads_.end(); |
||||||
|
thd = completed_threads_.erase(thd)) { |
||||||
|
delete *thd; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void ThreadManager::Initialize() { |
||||||
|
for (int i = 0; i < min_pollers_; i++) { |
||||||
|
MaybeCreatePoller(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// If the number of pollers (i.e threads currently blocked in PollForWork()) is
|
||||||
|
// less than max threshold (i.e max_pollers_) and the total number of threads is
|
||||||
|
// below the maximum threshold, we can let the current thread continue as poller
|
||||||
|
bool ThreadManager::MaybeContinueAsPoller() { |
||||||
|
std::unique_lock<grpc::mutex> lock(mu_); |
||||||
|
if (shutdown_ || num_pollers_ > max_pollers_) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
num_pollers_++; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
// Create a new poller if the current number of pollers i.e num_pollers_ (i.e
|
||||||
|
// threads currently blocked in PollForWork()) is below the threshold (i.e
|
||||||
|
// min_pollers_) and the total number of threads is below the maximum threshold
|
||||||
|
void ThreadManager::MaybeCreatePoller() { |
||||||
|
grpc::unique_lock<grpc::mutex> lock(mu_); |
||||||
|
if (!shutdown_ && num_pollers_ < min_pollers_) { |
||||||
|
num_pollers_++; |
||||||
|
num_threads_++; |
||||||
|
|
||||||
|
// Create a new thread (which ends up calling the MainWorkLoop() function
|
||||||
|
new WorkerThread(this); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void ThreadManager::MainWorkLoop() { |
||||||
|
void* tag; |
||||||
|
bool ok; |
||||||
|
|
||||||
|
/*
|
||||||
|
1. Poll for work (i.e PollForWork()) |
||||||
|
2. After returning from PollForWork, reduce the number of pollers by 1. If |
||||||
|
PollForWork() returned a TIMEOUT, then it may indicate that we have more |
||||||
|
polling threads than needed. Check if the number of pollers is greater |
||||||
|
than min_pollers and if so, terminate the thread. |
||||||
|
3. Since we are short of one poller now, see if a new poller has to be |
||||||
|
created (i.e see MaybeCreatePoller() for more details) |
||||||
|
4. Do the actual work (DoWork()) |
||||||
|
5. After doing the work, see it this thread can resume polling work (i.e |
||||||
|
see MaybeContinueAsPoller() for more details) */ |
||||||
|
do { |
||||||
|
WorkStatus work_status = PollForWork(&tag, &ok); |
||||||
|
|
||||||
|
{ |
||||||
|
grpc::unique_lock<grpc::mutex> lock(mu_); |
||||||
|
num_pollers_--; |
||||||
|
|
||||||
|
if (work_status == TIMEOUT && num_pollers_ > min_pollers_) { |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// Note that MaybeCreatePoller does check for shutdown and creates a new
|
||||||
|
// thread only if ThreadManager is not shutdown
|
||||||
|
if (work_status == WORK_FOUND) { |
||||||
|
MaybeCreatePoller(); |
||||||
|
DoWork(tag, ok); |
||||||
|
} |
||||||
|
} while (MaybeContinueAsPoller()); |
||||||
|
|
||||||
|
CleanupCompletedThreads(); |
||||||
|
|
||||||
|
// If we are here, either ThreadManager is shutting down or it already has
|
||||||
|
// enough threads.
|
||||||
|
} |
||||||
|
|
||||||
|
} // namespace grpc
|
@ -0,0 +1,159 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef GRPC_INTERNAL_CPP_THREAD_MANAGER_H |
||||||
|
#define GRPC_INTERNAL_CPP_THREAD_MANAGER_H |
||||||
|
|
||||||
|
#include <list> |
||||||
|
#include <memory> |
||||||
|
|
||||||
|
#include <grpc++/impl/sync.h> |
||||||
|
#include <grpc++/impl/thd.h> |
||||||
|
#include <grpc++/support/config.h> |
||||||
|
|
||||||
|
namespace grpc { |
||||||
|
|
||||||
|
class ThreadManager { |
||||||
|
public: |
||||||
|
explicit ThreadManager(int min_pollers, int max_pollers); |
||||||
|
virtual ~ThreadManager(); |
||||||
|
|
||||||
|
// Initializes and Starts the Rpc Manager threads
|
||||||
|
void Initialize(); |
||||||
|
|
||||||
|
// The return type of PollForWork() function
|
||||||
|
enum WorkStatus { WORK_FOUND, SHUTDOWN, TIMEOUT }; |
||||||
|
|
||||||
|
// "Polls" for new work.
|
||||||
|
// If the return value is WORK_FOUND:
|
||||||
|
// - The implementaion of PollForWork() MAY set some opaque identifier to
|
||||||
|
// (identify the work item found) via the '*tag' parameter
|
||||||
|
// - The implementaion MUST set the value of 'ok' to 'true' or 'false'. A
|
||||||
|
// value of 'false' indicates some implemenation specific error (that is
|
||||||
|
// neither SHUTDOWN nor TIMEOUT)
|
||||||
|
// - ThreadManager does not interpret the values of 'tag' and 'ok'
|
||||||
|
// - ThreadManager WILL call DoWork() and pass '*tag' and 'ok' as input to
|
||||||
|
// DoWork()
|
||||||
|
//
|
||||||
|
// If the return value is SHUTDOWN:,
|
||||||
|
// - ThreadManager WILL NOT call DoWork() and terminates the thead
|
||||||
|
//
|
||||||
|
// If the return value is TIMEOUT:,
|
||||||
|
// - ThreadManager WILL NOT call DoWork()
|
||||||
|
// - ThreadManager MAY terminate the thread depending on the current number
|
||||||
|
// of active poller threads and mix_pollers/max_pollers settings
|
||||||
|
// - Also, the value of timeout is specific to the derived class
|
||||||
|
// implementation
|
||||||
|
virtual WorkStatus PollForWork(void** tag, bool* ok) = 0; |
||||||
|
|
||||||
|
// The implementation of DoWork() is supposed to perform the work found by
|
||||||
|
// PollForWork(). The tag and ok parameters are the same as returned by
|
||||||
|
// PollForWork()
|
||||||
|
//
|
||||||
|
// The implementation of DoWork() should also do any setup needed to ensure
|
||||||
|
// that the next call to PollForWork() (not necessarily by the current thread)
|
||||||
|
// actually finds some work
|
||||||
|
virtual void DoWork(void* tag, bool ok) = 0; |
||||||
|
|
||||||
|
// Mark the ThreadManager as shutdown and begin draining the work. This is a
|
||||||
|
// non-blocking call and the caller should call Wait(), a blocking call which
|
||||||
|
// returns only once the shutdown is complete
|
||||||
|
void Shutdown(); |
||||||
|
|
||||||
|
// Has Shutdown() been called
|
||||||
|
bool IsShutdown(); |
||||||
|
|
||||||
|
// A blocking call that returns only after the ThreadManager has shutdown and
|
||||||
|
// all the threads have drained all the outstanding work
|
||||||
|
void Wait(); |
||||||
|
|
||||||
|
private: |
||||||
|
// Helper wrapper class around std::thread. This takes a ThreadManager object
|
||||||
|
// and starts a new std::thread to calls the Run() function.
|
||||||
|
//
|
||||||
|
// The Run() function calls ThreadManager::MainWorkLoop() function and once
|
||||||
|
// that completes, it marks the WorkerThread completed by calling
|
||||||
|
// ThreadManager::MarkAsCompleted()
|
||||||
|
class WorkerThread { |
||||||
|
public: |
||||||
|
WorkerThread(ThreadManager* thd_mgr); |
||||||
|
~WorkerThread(); |
||||||
|
|
||||||
|
private: |
||||||
|
// Calls thd_mgr_->MainWorkLoop() and once that completes, calls
|
||||||
|
// thd_mgr_>MarkAsCompleted(this) to mark the thread as completed
|
||||||
|
void Run(); |
||||||
|
|
||||||
|
ThreadManager* thd_mgr_; |
||||||
|
grpc::thread thd_; |
||||||
|
}; |
||||||
|
|
||||||
|
// The main funtion in ThreadManager
|
||||||
|
void MainWorkLoop(); |
||||||
|
|
||||||
|
// Create a new poller if the number of current pollers is less than the
|
||||||
|
// minimum number of pollers needed (i.e min_pollers).
|
||||||
|
void MaybeCreatePoller(); |
||||||
|
|
||||||
|
// Returns true if the current thread can resume as a poller. i.e if the
|
||||||
|
// current number of pollers is less than the max_pollers.
|
||||||
|
bool MaybeContinueAsPoller(); |
||||||
|
|
||||||
|
void MarkAsCompleted(WorkerThread* thd); |
||||||
|
void CleanupCompletedThreads(); |
||||||
|
|
||||||
|
// Protects shutdown_, num_pollers_ and num_threads_
|
||||||
|
// TODO: sreek - Change num_pollers and num_threads_ to atomics
|
||||||
|
grpc::mutex mu_; |
||||||
|
|
||||||
|
bool shutdown_; |
||||||
|
grpc::condition_variable shutdown_cv_; |
||||||
|
|
||||||
|
// Number of threads doing polling
|
||||||
|
int num_pollers_; |
||||||
|
|
||||||
|
// The minimum and maximum number of threads that should be doing polling
|
||||||
|
int min_pollers_; |
||||||
|
int max_pollers_; |
||||||
|
|
||||||
|
// The total number of threads (includes threads includes the threads that are
|
||||||
|
// currently polling i.e num_pollers_)
|
||||||
|
int num_threads_; |
||||||
|
|
||||||
|
grpc::mutex list_mu_; |
||||||
|
std::list<WorkerThread*> completed_threads_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace grpc
|
||||||
|
|
||||||
|
#endif // GRPC_INTERNAL_CPP_THREAD_MANAGER_H
|
@ -0,0 +1,37 @@ |
|||||||
|
|
||||||
|
// Copyright 2016, Google Inc. |
||||||
|
// All rights reserved. |
||||||
|
// |
||||||
|
// Redistribution and use in source and binary forms, with or without |
||||||
|
// modification, are permitted provided that the following conditions are |
||||||
|
// met: |
||||||
|
// |
||||||
|
// * Redistributions of source code must retain the above copyright |
||||||
|
// notice, this list of conditions and the following disclaimer. |
||||||
|
// * Redistributions in binary form must reproduce the above |
||||||
|
// copyright notice, this list of conditions and the following disclaimer |
||||||
|
// in the documentation and/or other materials provided with the |
||||||
|
// distribution. |
||||||
|
// * Neither the name of Google Inc. nor the names of its |
||||||
|
// contributors may be used to endorse or promote products derived from |
||||||
|
// this software without specific prior written permission. |
||||||
|
// |
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
syntax = "proto2"; |
||||||
|
|
||||||
|
package grpc.testing.proto2; |
||||||
|
|
||||||
|
message EmptyWithExtensions { |
||||||
|
extensions 100 to 999; |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
// Copyright 2016, Google Inc. |
||||||
|
// All rights reserved. |
||||||
|
// |
||||||
|
// Redistribution and use in source and binary forms, with or without |
||||||
|
// modification, are permitted provided that the following conditions are |
||||||
|
// met: |
||||||
|
// |
||||||
|
// * Redistributions of source code must retain the above copyright |
||||||
|
// notice, this list of conditions and the following disclaimer. |
||||||
|
// * Redistributions in binary form must reproduce the above |
||||||
|
// copyright notice, this list of conditions and the following disclaimer |
||||||
|
// in the documentation and/or other materials provided with the |
||||||
|
// distribution. |
||||||
|
// * Neither the name of Google Inc. nor the names of its |
||||||
|
// contributors may be used to endorse or promote products derived from |
||||||
|
// this software without specific prior written permission. |
||||||
|
// |
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
syntax = "proto2"; |
||||||
|
|
||||||
|
import "src/proto/grpc/testing/proto2/empty2.proto"; |
||||||
|
|
||||||
|
package grpc.testing.proto2; |
||||||
|
|
||||||
|
// Fill emptiness with music. |
||||||
|
extend grpc.testing.proto2.EmptyWithExtensions { |
||||||
|
optional int64 Deadmau5 = 124; |
||||||
|
optional float Madeon = 125; |
||||||
|
optional string AboveAndBeyond = 126; |
||||||
|
optional bool Tycho = 127; |
||||||
|
optional fixed64 Pendulum = 128; |
||||||
|
} |
@ -1 +1,3 @@ |
|||||||
gens/ |
gens/ |
||||||
|
*_pb2.py |
||||||
|
*_pb2_grpc.py |
||||||
|
@ -1,5 +1,6 @@ |
|||||||
*.proto |
*.proto |
||||||
*_pb2.py |
*_pb2.py |
||||||
|
*_pb2_grpc.py |
||||||
build/ |
build/ |
||||||
grpcio_health_checking.egg-info/ |
grpcio_health_checking.egg-info/ |
||||||
dist/ |
dist/ |
||||||
|
@ -0,0 +1,5 @@ |
|||||||
|
*.proto |
||||||
|
*_pb2.py |
||||||
|
build/ |
||||||
|
grpcio_reflection.egg-info/ |
||||||
|
dist/ |
@ -0,0 +1,30 @@ |
|||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
__import__('pkg_resources').declare_namespace(__name__) |
@ -0,0 +1,29 @@ |
|||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
@ -0,0 +1,29 @@ |
|||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
@ -0,0 +1,143 @@ |
|||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
"""Reference implementation for reflection in gRPC Python.""" |
||||||
|
|
||||||
|
import threading |
||||||
|
|
||||||
|
import grpc |
||||||
|
from google.protobuf import descriptor_pb2 |
||||||
|
from google.protobuf import descriptor_pool |
||||||
|
|
||||||
|
from grpc.reflection.v1alpha import reflection_pb2 |
||||||
|
|
||||||
|
_POOL = descriptor_pool.Default() |
||||||
|
|
||||||
|
def _not_found_error(): |
||||||
|
return reflection_pb2.ServerReflectionResponse( |
||||||
|
error_response=reflection_pb2.ErrorResponse( |
||||||
|
error_code=grpc.StatusCode.NOT_FOUND.value[0], |
||||||
|
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(), |
||||||
|
) |
||||||
|
) |
||||||
|
|
||||||
|
def _file_descriptor_response(descriptor): |
||||||
|
proto = descriptor_pb2.FileDescriptorProto() |
||||||
|
descriptor.CopyToProto(proto) |
||||||
|
serialized_proto = proto.SerializeToString() |
||||||
|
return reflection_pb2.ServerReflectionResponse( |
||||||
|
file_descriptor_response=reflection_pb2.FileDescriptorResponse( |
||||||
|
file_descriptor_proto=(serialized_proto,) |
||||||
|
), |
||||||
|
) |
||||||
|
|
||||||
|
|
||||||
|
class ReflectionServicer(reflection_pb2.ServerReflectionServicer): |
||||||
|
"""Servicer handling RPCs for service statuses.""" |
||||||
|
|
||||||
|
def __init__(self, service_names, pool=None): |
||||||
|
"""Constructor. |
||||||
|
|
||||||
|
Args: |
||||||
|
service_names: Iterable of fully-qualified service names available. |
||||||
|
""" |
||||||
|
self._service_names = list(service_names) |
||||||
|
self._pool = _POOL if pool is None else pool |
||||||
|
|
||||||
|
def _file_by_filename(self, filename): |
||||||
|
try: |
||||||
|
descriptor = self._pool.FindFileByName(filename) |
||||||
|
except KeyError: |
||||||
|
return _not_found_error() |
||||||
|
else: |
||||||
|
return _file_descriptor_response(descriptor) |
||||||
|
|
||||||
|
def _file_containing_symbol(self, fully_qualified_name): |
||||||
|
try: |
||||||
|
descriptor = self._pool.FindFileContainingSymbol(fully_qualified_name) |
||||||
|
except KeyError: |
||||||
|
return _not_found_error() |
||||||
|
else: |
||||||
|
return _file_descriptor_response(descriptor) |
||||||
|
|
||||||
|
def _file_containing_extension(containing_type, extension_number): |
||||||
|
# TODO(atash) Python protobuf currently doesn't support querying extensions. |
||||||
|
# https://github.com/google/protobuf/issues/2248 |
||||||
|
return reflection_pb2.ServerReflectionResponse( |
||||||
|
error_response=reflection_pb2.ErrorResponse( |
||||||
|
error_code=grpc.StatusCode.UNIMPLEMENTED.value[0], |
||||||
|
error_message=grpc.StatusCode.UNIMPLMENTED.value[1].encode(), |
||||||
|
) |
||||||
|
) |
||||||
|
|
||||||
|
def _extension_numbers_of_type(fully_qualified_name): |
||||||
|
# TODO(atash) We're allowed to leave this unsupported according to the |
||||||
|
# protocol, but we should still eventually implement it. Hits the same issue |
||||||
|
# as `_file_containing_extension`, however. |
||||||
|
# https://github.com/google/protobuf/issues/2248 |
||||||
|
return reflection_pb2.ServerReflectionResponse( |
||||||
|
error_response=reflection_pb2.ErrorResponse( |
||||||
|
error_code=grpc.StatusCode.UNIMPLEMENTED.value[0], |
||||||
|
error_message=grpc.StatusCode.UNIMPLMENTED.value[1].encode(), |
||||||
|
) |
||||||
|
) |
||||||
|
|
||||||
|
def _list_services(self): |
||||||
|
return reflection_pb2.ServerReflectionResponse( |
||||||
|
list_services_response=reflection_pb2.ListServiceResponse( |
||||||
|
service=[ |
||||||
|
reflection_pb2.ServiceResponse(name=service_name) |
||||||
|
for service_name in self._service_names |
||||||
|
] |
||||||
|
) |
||||||
|
) |
||||||
|
|
||||||
|
def ServerReflectionInfo(self, request_iterator, context): |
||||||
|
for request in request_iterator: |
||||||
|
if request.HasField('file_by_filename'): |
||||||
|
yield self._file_by_filename(request.file_by_filename) |
||||||
|
elif request.HasField('file_containing_symbol'): |
||||||
|
yield self._file_containing_symbol(request.file_containing_symbol) |
||||||
|
elif request.HasField('file_containing_extension'): |
||||||
|
yield self._file_containing_extension( |
||||||
|
request.file_containing_extension.containing_type, |
||||||
|
request.file_containing_extension.extension_number) |
||||||
|
elif request.HasField('all_extension_numbers_of_type'): |
||||||
|
yield _all_extension_numbers_of_type( |
||||||
|
request.all_extension_numbers_of_type) |
||||||
|
elif request.HasField('list_services'): |
||||||
|
yield self._list_services() |
||||||
|
else: |
||||||
|
yield reflection_pb2.ServerReflectionResponse( |
||||||
|
error_response=reflection_pb2.ErrorResponse( |
||||||
|
error_code=grpc.StatusCode.INVALID_ARGUMENT.value[0], |
||||||
|
error_message=grpc.StatusCode.INVALID_ARGUMENT.value[1].encode(), |
||||||
|
) |
||||||
|
) |
||||||
|
|
@ -0,0 +1,32 @@ |
|||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! |
||||||
|
|
||||||
|
VERSION='1.1.0.dev0' |
@ -0,0 +1,78 @@ |
|||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
"""Provides distutils command classes for the GRPC Python setup process.""" |
||||||
|
|
||||||
|
import os |
||||||
|
import shutil |
||||||
|
|
||||||
|
import setuptools |
||||||
|
|
||||||
|
ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__))) |
||||||
|
HEALTH_PROTO = os.path.join(ROOT_DIR, '../../proto/grpc/reflection/v1alpha/reflection.proto') |
||||||
|
|
||||||
|
|
||||||
|
class CopyProtoModules(setuptools.Command): |
||||||
|
"""Command to copy proto modules from grpc/src/proto.""" |
||||||
|
|
||||||
|
description = '' |
||||||
|
user_options = [] |
||||||
|
|
||||||
|
def initialize_options(self): |
||||||
|
pass |
||||||
|
|
||||||
|
def finalize_options(self): |
||||||
|
pass |
||||||
|
|
||||||
|
def run(self): |
||||||
|
if os.path.isfile(HEALTH_PROTO): |
||||||
|
shutil.copyfile( |
||||||
|
HEALTH_PROTO, |
||||||
|
os.path.join(ROOT_DIR, 'grpc/reflection/v1alpha/reflection.proto')) |
||||||
|
|
||||||
|
|
||||||
|
class BuildPackageProtos(setuptools.Command): |
||||||
|
"""Command to generate project *_pb2.py modules from proto files.""" |
||||||
|
|
||||||
|
description = 'build grpc protobuf modules' |
||||||
|
user_options = [] |
||||||
|
|
||||||
|
def initialize_options(self): |
||||||
|
pass |
||||||
|
|
||||||
|
def finalize_options(self): |
||||||
|
pass |
||||||
|
|
||||||
|
def run(self): |
||||||
|
# due to limitations of the proto generator, we require that only *one* |
||||||
|
# directory is provided as an 'include' directory. We assume it's the '' key |
||||||
|
# to `self.distribution.package_dir` (and get a key error if it's not |
||||||
|
# there). |
||||||
|
from grpc.tools import command |
||||||
|
command.build_package_protos(self.distribution.package_dir['']) |
@ -0,0 +1,73 @@ |
|||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
"""Setup module for the GRPC Python package's optional reflection.""" |
||||||
|
|
||||||
|
import os |
||||||
|
import sys |
||||||
|
|
||||||
|
import setuptools |
||||||
|
|
||||||
|
# Ensure we're in the proper directory whether or not we're being used by pip. |
||||||
|
os.chdir(os.path.dirname(os.path.abspath(__file__))) |
||||||
|
|
||||||
|
# Break import-style to ensure we can actually find our commands module. |
||||||
|
import reflection_commands |
||||||
|
import grpc_version |
||||||
|
|
||||||
|
PACKAGE_DIRECTORIES = { |
||||||
|
'': '.', |
||||||
|
} |
||||||
|
|
||||||
|
SETUP_REQUIRES = ( |
||||||
|
'grpcio-tools>={version}'.format(version=grpc_version.VERSION), |
||||||
|
) |
||||||
|
|
||||||
|
INSTALL_REQUIRES = ( |
||||||
|
'protobuf>=3.0.0', |
||||||
|
'grpcio>={version}'.format(version=grpc_version.VERSION), |
||||||
|
) |
||||||
|
|
||||||
|
COMMAND_CLASS = { |
||||||
|
# Run preprocess from the repository *before* doing any packaging! |
||||||
|
'preprocess': reflection_commands.CopyProtoModules, |
||||||
|
'build_package_protos': reflection_commands.BuildPackageProtos, |
||||||
|
} |
||||||
|
|
||||||
|
setuptools.setup( |
||||||
|
name='grpcio-reflection', |
||||||
|
version=grpc_version.VERSION, |
||||||
|
license='3-clause BSD', |
||||||
|
package_dir=PACKAGE_DIRECTORIES, |
||||||
|
packages=setuptools.find_packages('.'), |
||||||
|
namespace_packages=['grpc'], |
||||||
|
install_requires=INSTALL_REQUIRES, |
||||||
|
setup_requires=SETUP_REQUIRES, |
||||||
|
cmdclass=COMMAND_CLASS |
||||||
|
) |
@ -1,4 +1,5 @@ |
|||||||
proto/ |
proto/ |
||||||
src/ |
src/ |
||||||
*_pb2.py |
*_pb2.py |
||||||
|
*_pb2_grpc.py |
||||||
*.egg-info/ |
*.egg-info/ |
||||||
|
@ -0,0 +1,304 @@ |
|||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
import collections |
||||||
|
from concurrent import futures |
||||||
|
import contextlib |
||||||
|
import distutils.spawn |
||||||
|
import errno |
||||||
|
import importlib |
||||||
|
import os |
||||||
|
import os.path |
||||||
|
import pkgutil |
||||||
|
import shutil |
||||||
|
import subprocess |
||||||
|
import sys |
||||||
|
import tempfile |
||||||
|
import threading |
||||||
|
import unittest |
||||||
|
|
||||||
|
import grpc |
||||||
|
from grpc.tools import protoc |
||||||
|
from tests.unit.framework.common import test_constants |
||||||
|
|
||||||
|
_MESSAGES_IMPORT = b'import "messages.proto";' |
||||||
|
|
||||||
|
@contextlib.contextmanager |
||||||
|
def _system_path(path): |
||||||
|
old_system_path = sys.path[:] |
||||||
|
sys.path = sys.path[0:1] + path + sys.path[1:] |
||||||
|
yield |
||||||
|
sys.path = old_system_path |
||||||
|
|
||||||
|
|
||||||
|
class DummySplitServicer(object): |
||||||
|
|
||||||
|
def __init__(self, request_class, response_class): |
||||||
|
self.request_class = request_class |
||||||
|
self.response_class = response_class |
||||||
|
|
||||||
|
def Call(self, request, context): |
||||||
|
return self.response_class() |
||||||
|
|
||||||
|
|
||||||
|
class SeparateTestMixin(object): |
||||||
|
|
||||||
|
def testImportAttributes(self): |
||||||
|
with _system_path([self.python_out_directory]): |
||||||
|
pb2 = importlib.import_module(self.pb2_import) |
||||||
|
pb2.Request |
||||||
|
pb2.Response |
||||||
|
if self.should_find_services_in_pb2: |
||||||
|
pb2.TestServiceServicer |
||||||
|
else: |
||||||
|
with self.assertRaises(AttributeError): |
||||||
|
pb2.TestServiceServicer |
||||||
|
|
||||||
|
with _system_path([self.grpc_python_out_directory]): |
||||||
|
pb2_grpc = importlib.import_module(self.pb2_grpc_import) |
||||||
|
pb2_grpc.TestServiceServicer |
||||||
|
with self.assertRaises(AttributeError): |
||||||
|
pb2_grpc.Request |
||||||
|
with self.assertRaises(AttributeError): |
||||||
|
pb2_grpc.Response |
||||||
|
|
||||||
|
def testCall(self): |
||||||
|
with _system_path([self.python_out_directory]): |
||||||
|
pb2 = importlib.import_module(self.pb2_import) |
||||||
|
with _system_path([self.grpc_python_out_directory]): |
||||||
|
pb2_grpc = importlib.import_module(self.pb2_grpc_import) |
||||||
|
server = grpc.server( |
||||||
|
futures.ThreadPoolExecutor(max_workers=test_constants.POOL_SIZE)) |
||||||
|
pb2_grpc.add_TestServiceServicer_to_server( |
||||||
|
DummySplitServicer( |
||||||
|
pb2.Request, pb2.Response), server) |
||||||
|
port = server.add_insecure_port('[::]:0') |
||||||
|
server.start() |
||||||
|
channel = grpc.insecure_channel('localhost:{}'.format(port)) |
||||||
|
stub = pb2_grpc.TestServiceStub(channel) |
||||||
|
request = pb2.Request() |
||||||
|
expected_response = pb2.Response() |
||||||
|
response = stub.Call(request) |
||||||
|
self.assertEqual(expected_response, response) |
||||||
|
|
||||||
|
|
||||||
|
class CommonTestMixin(object): |
||||||
|
|
||||||
|
def testImportAttributes(self): |
||||||
|
with _system_path([self.python_out_directory]): |
||||||
|
pb2 = importlib.import_module(self.pb2_import) |
||||||
|
pb2.Request |
||||||
|
pb2.Response |
||||||
|
if self.should_find_services_in_pb2: |
||||||
|
pb2.TestServiceServicer |
||||||
|
else: |
||||||
|
with self.assertRaises(AttributeError): |
||||||
|
pb2.TestServiceServicer |
||||||
|
|
||||||
|
with _system_path([self.grpc_python_out_directory]): |
||||||
|
pb2_grpc = importlib.import_module(self.pb2_grpc_import) |
||||||
|
pb2_grpc.TestServiceServicer |
||||||
|
with self.assertRaises(AttributeError): |
||||||
|
pb2_grpc.Request |
||||||
|
with self.assertRaises(AttributeError): |
||||||
|
pb2_grpc.Response |
||||||
|
|
||||||
|
def testCall(self): |
||||||
|
with _system_path([self.python_out_directory]): |
||||||
|
pb2 = importlib.import_module(self.pb2_import) |
||||||
|
with _system_path([self.grpc_python_out_directory]): |
||||||
|
pb2_grpc = importlib.import_module(self.pb2_grpc_import) |
||||||
|
server = grpc.server( |
||||||
|
futures.ThreadPoolExecutor(max_workers=test_constants.POOL_SIZE)) |
||||||
|
pb2_grpc.add_TestServiceServicer_to_server( |
||||||
|
DummySplitServicer( |
||||||
|
pb2.Request, pb2.Response), server) |
||||||
|
port = server.add_insecure_port('[::]:0') |
||||||
|
server.start() |
||||||
|
channel = grpc.insecure_channel('localhost:{}'.format(port)) |
||||||
|
stub = pb2_grpc.TestServiceStub(channel) |
||||||
|
request = pb2.Request() |
||||||
|
expected_response = pb2.Response() |
||||||
|
response = stub.Call(request) |
||||||
|
self.assertEqual(expected_response, response) |
||||||
|
|
||||||
|
|
||||||
|
class SameSeparateTest(unittest.TestCase, SeparateTestMixin): |
||||||
|
|
||||||
|
def setUp(self): |
||||||
|
same_proto_contents = pkgutil.get_data( |
||||||
|
'tests.protoc_plugin.protos.invocation_testing', 'same.proto') |
||||||
|
self.directory = tempfile.mkdtemp(suffix='same_separate', dir='.') |
||||||
|
self.proto_directory = os.path.join(self.directory, 'proto_path') |
||||||
|
self.python_out_directory = os.path.join(self.directory, 'python_out') |
||||||
|
self.grpc_python_out_directory = os.path.join(self.directory, 'grpc_python_out') |
||||||
|
os.makedirs(self.proto_directory) |
||||||
|
os.makedirs(self.python_out_directory) |
||||||
|
os.makedirs(self.grpc_python_out_directory) |
||||||
|
same_proto_file = os.path.join(self.proto_directory, 'same_separate.proto') |
||||||
|
open(same_proto_file, 'wb').write(same_proto_contents) |
||||||
|
protoc_result = protoc.main([ |
||||||
|
'', |
||||||
|
'--proto_path={}'.format(self.proto_directory), |
||||||
|
'--python_out={}'.format(self.python_out_directory), |
||||||
|
'--grpc_python_out={}'.format(self.grpc_python_out_directory), |
||||||
|
same_proto_file, |
||||||
|
]) |
||||||
|
if protoc_result != 0: |
||||||
|
raise Exception("unexpected protoc error") |
||||||
|
open(os.path.join(self.grpc_python_out_directory, '__init__.py'), 'w').write('') |
||||||
|
open(os.path.join(self.python_out_directory, '__init__.py'), 'w').write('') |
||||||
|
self.pb2_import = 'same_separate_pb2' |
||||||
|
self.pb2_grpc_import = 'same_separate_pb2_grpc' |
||||||
|
self.should_find_services_in_pb2 = False |
||||||
|
|
||||||
|
def tearDown(self): |
||||||
|
shutil.rmtree(self.directory) |
||||||
|
|
||||||
|
|
||||||
|
class SameCommonTest(unittest.TestCase, CommonTestMixin): |
||||||
|
|
||||||
|
def setUp(self): |
||||||
|
same_proto_contents = pkgutil.get_data( |
||||||
|
'tests.protoc_plugin.protos.invocation_testing', 'same.proto') |
||||||
|
self.directory = tempfile.mkdtemp(suffix='same_common', dir='.') |
||||||
|
self.proto_directory = os.path.join(self.directory, 'proto_path') |
||||||
|
self.python_out_directory = os.path.join(self.directory, 'python_out') |
||||||
|
self.grpc_python_out_directory = self.python_out_directory |
||||||
|
os.makedirs(self.proto_directory) |
||||||
|
os.makedirs(self.python_out_directory) |
||||||
|
same_proto_file = os.path.join(self.proto_directory, 'same_common.proto') |
||||||
|
open(same_proto_file, 'wb').write(same_proto_contents) |
||||||
|
protoc_result = protoc.main([ |
||||||
|
'', |
||||||
|
'--proto_path={}'.format(self.proto_directory), |
||||||
|
'--python_out={}'.format(self.python_out_directory), |
||||||
|
'--grpc_python_out={}'.format(self.grpc_python_out_directory), |
||||||
|
same_proto_file, |
||||||
|
]) |
||||||
|
if protoc_result != 0: |
||||||
|
raise Exception("unexpected protoc error") |
||||||
|
open(os.path.join(self.python_out_directory, '__init__.py'), 'w').write('') |
||||||
|
self.pb2_import = 'same_common_pb2' |
||||||
|
self.pb2_grpc_import = 'same_common_pb2_grpc' |
||||||
|
self.should_find_services_in_pb2 = True |
||||||
|
|
||||||
|
def tearDown(self): |
||||||
|
shutil.rmtree(self.directory) |
||||||
|
|
||||||
|
|
||||||
|
class SplitCommonTest(unittest.TestCase, CommonTestMixin): |
||||||
|
|
||||||
|
def setUp(self): |
||||||
|
services_proto_contents = pkgutil.get_data( |
||||||
|
'tests.protoc_plugin.protos.invocation_testing.split_services', |
||||||
|
'services.proto') |
||||||
|
messages_proto_contents = pkgutil.get_data( |
||||||
|
'tests.protoc_plugin.protos.invocation_testing.split_messages', |
||||||
|
'messages.proto') |
||||||
|
self.directory = tempfile.mkdtemp(suffix='split_common', dir='.') |
||||||
|
self.proto_directory = os.path.join(self.directory, 'proto_path') |
||||||
|
self.python_out_directory = os.path.join(self.directory, 'python_out') |
||||||
|
self.grpc_python_out_directory = self.python_out_directory |
||||||
|
os.makedirs(self.proto_directory) |
||||||
|
os.makedirs(self.python_out_directory) |
||||||
|
services_proto_file = os.path.join(self.proto_directory, |
||||||
|
'split_common_services.proto') |
||||||
|
messages_proto_file = os.path.join(self.proto_directory, |
||||||
|
'split_common_messages.proto') |
||||||
|
open(services_proto_file, 'wb').write(services_proto_contents.replace( |
||||||
|
_MESSAGES_IMPORT, |
||||||
|
b'import "split_common_messages.proto";' |
||||||
|
)) |
||||||
|
open(messages_proto_file, 'wb').write(messages_proto_contents) |
||||||
|
protoc_result = protoc.main([ |
||||||
|
'', |
||||||
|
'--proto_path={}'.format(self.proto_directory), |
||||||
|
'--python_out={}'.format(self.python_out_directory), |
||||||
|
'--grpc_python_out={}'.format(self.python_out_directory), |
||||||
|
services_proto_file, |
||||||
|
messages_proto_file, |
||||||
|
]) |
||||||
|
if protoc_result != 0: |
||||||
|
raise Exception("unexpected protoc error") |
||||||
|
open(os.path.join(self.python_out_directory, '__init__.py'), 'w').write('') |
||||||
|
self.pb2_import = 'split_common_messages_pb2' |
||||||
|
self.pb2_grpc_import = 'split_common_services_pb2_grpc' |
||||||
|
self.should_find_services_in_pb2 = False |
||||||
|
|
||||||
|
def tearDown(self): |
||||||
|
shutil.rmtree(self.directory) |
||||||
|
|
||||||
|
|
||||||
|
class SplitSeparateTest(unittest.TestCase, SeparateTestMixin): |
||||||
|
|
||||||
|
def setUp(self): |
||||||
|
services_proto_contents = pkgutil.get_data( |
||||||
|
'tests.protoc_plugin.protos.invocation_testing.split_services', |
||||||
|
'services.proto') |
||||||
|
messages_proto_contents = pkgutil.get_data( |
||||||
|
'tests.protoc_plugin.protos.invocation_testing.split_messages', |
||||||
|
'messages.proto') |
||||||
|
self.directory = tempfile.mkdtemp(suffix='split_separate', dir='.') |
||||||
|
self.proto_directory = os.path.join(self.directory, 'proto_path') |
||||||
|
self.python_out_directory = os.path.join(self.directory, 'python_out') |
||||||
|
self.grpc_python_out_directory = os.path.join(self.directory, 'grpc_python_out') |
||||||
|
os.makedirs(self.proto_directory) |
||||||
|
os.makedirs(self.python_out_directory) |
||||||
|
os.makedirs(self.grpc_python_out_directory) |
||||||
|
services_proto_file = os.path.join(self.proto_directory, |
||||||
|
'split_separate_services.proto') |
||||||
|
messages_proto_file = os.path.join(self.proto_directory, |
||||||
|
'split_separate_messages.proto') |
||||||
|
open(services_proto_file, 'wb').write(services_proto_contents.replace( |
||||||
|
_MESSAGES_IMPORT, |
||||||
|
b'import "split_separate_messages.proto";' |
||||||
|
)) |
||||||
|
open(messages_proto_file, 'wb').write(messages_proto_contents) |
||||||
|
protoc_result = protoc.main([ |
||||||
|
'', |
||||||
|
'--proto_path={}'.format(self.proto_directory), |
||||||
|
'--python_out={}'.format(self.python_out_directory), |
||||||
|
'--grpc_python_out={}'.format(self.grpc_python_out_directory), |
||||||
|
services_proto_file, |
||||||
|
messages_proto_file, |
||||||
|
]) |
||||||
|
if protoc_result != 0: |
||||||
|
raise Exception("unexpected protoc error") |
||||||
|
open(os.path.join(self.python_out_directory, '__init__.py'), 'w').write('') |
||||||
|
self.pb2_import = 'split_separate_messages_pb2' |
||||||
|
self.pb2_grpc_import = 'split_separate_services_pb2_grpc' |
||||||
|
self.should_find_services_in_pb2 = False |
||||||
|
|
||||||
|
def tearDown(self): |
||||||
|
shutil.rmtree(self.directory) |
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__': |
||||||
|
unittest.main(verbosity=2) |
@ -0,0 +1,30 @@ |
|||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
|
@ -0,0 +1,39 @@ |
|||||||
|
// Copyright 2016, Google Inc. |
||||||
|
// All rights reserved. |
||||||
|
// |
||||||
|
// Redistribution and use in source and binary forms, with or without |
||||||
|
// modification, are permitted provided that the following conditions are |
||||||
|
// met: |
||||||
|
// |
||||||
|
// * Redistributions of source code must retain the above copyright |
||||||
|
// notice, this list of conditions and the following disclaimer. |
||||||
|
// * Redistributions in binary form must reproduce the above |
||||||
|
// copyright notice, this list of conditions and the following disclaimer |
||||||
|
// in the documentation and/or other materials provided with the |
||||||
|
// distribution. |
||||||
|
// * Neither the name of Google Inc. nor the names of its |
||||||
|
// contributors may be used to endorse or promote products derived from |
||||||
|
// this software without specific prior written permission. |
||||||
|
// |
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
syntax = "proto3"; |
||||||
|
|
||||||
|
package grpc_protoc_plugin.invocation_testing; |
||||||
|
|
||||||
|
message Request {} |
||||||
|
message Response {} |
||||||
|
|
||||||
|
service TestService { |
||||||
|
rpc Call(Request) returns (Response); |
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
|
@ -0,0 +1,35 @@ |
|||||||
|
// Copyright 2016, Google Inc. |
||||||
|
// All rights reserved. |
||||||
|
// |
||||||
|
// Redistribution and use in source and binary forms, with or without |
||||||
|
// modification, are permitted provided that the following conditions are |
||||||
|
// met: |
||||||
|
// |
||||||
|
// * Redistributions of source code must retain the above copyright |
||||||
|
// notice, this list of conditions and the following disclaimer. |
||||||
|
// * Redistributions in binary form must reproduce the above |
||||||
|
// copyright notice, this list of conditions and the following disclaimer |
||||||
|
// in the documentation and/or other materials provided with the |
||||||
|
// distribution. |
||||||
|
// * Neither the name of Google Inc. nor the names of its |
||||||
|
// contributors may be used to endorse or promote products derived from |
||||||
|
// this software without specific prior written permission. |
||||||
|
// |
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
syntax = "proto3"; |
||||||
|
|
||||||
|
package grpc_protoc_plugin.invocation_testing.split; |
||||||
|
|
||||||
|
message Request {} |
||||||
|
message Response {} |
@ -0,0 +1,30 @@ |
|||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
|
@ -0,0 +1,38 @@ |
|||||||
|
// Copyright 2016, Google Inc. |
||||||
|
// All rights reserved. |
||||||
|
// |
||||||
|
// Redistribution and use in source and binary forms, with or without |
||||||
|
// modification, are permitted provided that the following conditions are |
||||||
|
// met: |
||||||
|
// |
||||||
|
// * Redistributions of source code must retain the above copyright |
||||||
|
// notice, this list of conditions and the following disclaimer. |
||||||
|
// * Redistributions in binary form must reproduce the above |
||||||
|
// copyright notice, this list of conditions and the following disclaimer |
||||||
|
// in the documentation and/or other materials provided with the |
||||||
|
// distribution. |
||||||
|
// * Neither the name of Google Inc. nor the names of its |
||||||
|
// contributors may be used to endorse or promote products derived from |
||||||
|
// this software without specific prior written permission. |
||||||
|
// |
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
syntax = "proto3"; |
||||||
|
|
||||||
|
import "messages.proto"; |
||||||
|
|
||||||
|
package grpc_protoc_plugin.invocation_testing.split; |
||||||
|
|
||||||
|
service TestService { |
||||||
|
rpc Call(Request) returns (Response); |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
@ -0,0 +1,185 @@ |
|||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
"""Tests of grpc.reflection.v1alpha.reflection.""" |
||||||
|
|
||||||
|
import unittest |
||||||
|
|
||||||
|
import grpc |
||||||
|
from grpc.framework.foundation import logging_pool |
||||||
|
from grpc.reflection.v1alpha import reflection |
||||||
|
from grpc.reflection.v1alpha import reflection_pb2 |
||||||
|
|
||||||
|
from google.protobuf import descriptor_pool |
||||||
|
from google.protobuf import descriptor_pb2 |
||||||
|
|
||||||
|
from src.proto.grpc.testing.proto2 import empty2_extensions_pb2 |
||||||
|
from src.proto.grpc.testing import empty_pb2 |
||||||
|
from tests.unit.framework.common import test_constants |
||||||
|
|
||||||
|
_EMPTY_PROTO_FILE_NAME = 'src/proto/grpc/testing/empty.proto' |
||||||
|
_EMPTY_PROTO_SYMBOL_NAME = 'grpc.testing.Empty' |
||||||
|
_SERVICE_NAMES = ( |
||||||
|
'Angstrom', 'Bohr', 'Curie', 'Dyson', 'Einstein', 'Feynman', 'Galilei') |
||||||
|
|
||||||
|
def _file_descriptor_to_proto(descriptor): |
||||||
|
proto = descriptor_pb2.FileDescriptorProto() |
||||||
|
descriptor.CopyToProto(proto) |
||||||
|
return proto.SerializeToString() |
||||||
|
|
||||||
|
class ReflectionServicerTest(unittest.TestCase): |
||||||
|
|
||||||
|
def setUp(self): |
||||||
|
servicer = reflection.ReflectionServicer(service_names=_SERVICE_NAMES) |
||||||
|
server_pool = logging_pool.pool(test_constants.THREAD_CONCURRENCY) |
||||||
|
self._server = grpc.server(server_pool) |
||||||
|
port = self._server.add_insecure_port('[::]:0') |
||||||
|
reflection_pb2.add_ServerReflectionServicer_to_server(servicer, self._server) |
||||||
|
self._server.start() |
||||||
|
|
||||||
|
channel = grpc.insecure_channel('localhost:%d' % port) |
||||||
|
self._stub = reflection_pb2.ServerReflectionStub(channel) |
||||||
|
|
||||||
|
def testFileByName(self): |
||||||
|
requests = ( |
||||||
|
reflection_pb2.ServerReflectionRequest( |
||||||
|
file_by_filename=_EMPTY_PROTO_FILE_NAME |
||||||
|
), |
||||||
|
reflection_pb2.ServerReflectionRequest( |
||||||
|
file_by_filename='i-donut-exist' |
||||||
|
), |
||||||
|
) |
||||||
|
responses = tuple(self._stub.ServerReflectionInfo(requests)) |
||||||
|
expected_responses = ( |
||||||
|
reflection_pb2.ServerReflectionResponse( |
||||||
|
valid_host='', |
||||||
|
file_descriptor_response=reflection_pb2.FileDescriptorResponse( |
||||||
|
file_descriptor_proto=( |
||||||
|
_file_descriptor_to_proto(empty_pb2.DESCRIPTOR), |
||||||
|
) |
||||||
|
) |
||||||
|
), |
||||||
|
reflection_pb2.ServerReflectionResponse( |
||||||
|
valid_host='', |
||||||
|
error_response=reflection_pb2.ErrorResponse( |
||||||
|
error_code=grpc.StatusCode.NOT_FOUND.value[0], |
||||||
|
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(), |
||||||
|
) |
||||||
|
), |
||||||
|
) |
||||||
|
self.assertEqual(expected_responses, responses) |
||||||
|
|
||||||
|
def testFileBySymbol(self): |
||||||
|
requests = ( |
||||||
|
reflection_pb2.ServerReflectionRequest( |
||||||
|
file_containing_symbol=_EMPTY_PROTO_SYMBOL_NAME |
||||||
|
), |
||||||
|
reflection_pb2.ServerReflectionRequest( |
||||||
|
file_containing_symbol='i.donut.exist.co.uk.org.net.me.name.foo' |
||||||
|
), |
||||||
|
) |
||||||
|
responses = tuple(self._stub.ServerReflectionInfo(requests)) |
||||||
|
expected_responses = ( |
||||||
|
reflection_pb2.ServerReflectionResponse( |
||||||
|
valid_host='', |
||||||
|
file_descriptor_response=reflection_pb2.FileDescriptorResponse( |
||||||
|
file_descriptor_proto=( |
||||||
|
_file_descriptor_to_proto(empty_pb2.DESCRIPTOR), |
||||||
|
) |
||||||
|
) |
||||||
|
), |
||||||
|
reflection_pb2.ServerReflectionResponse( |
||||||
|
valid_host='', |
||||||
|
error_response=reflection_pb2.ErrorResponse( |
||||||
|
error_code=grpc.StatusCode.NOT_FOUND.value[0], |
||||||
|
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(), |
||||||
|
) |
||||||
|
), |
||||||
|
) |
||||||
|
self.assertEqual(expected_responses, responses) |
||||||
|
|
||||||
|
@unittest.skip('TODO(atash): implement file-containing-extension reflection ' |
||||||
|
'(see https://github.com/google/protobuf/issues/2248)') |
||||||
|
def testFileContainingExtension(self): |
||||||
|
requests = ( |
||||||
|
reflection_pb2.ServerReflectionRequest( |
||||||
|
file_containing_extension=reflection_pb2.ExtensionRequest( |
||||||
|
containing_type='grpc.testing.proto2.Empty', |
||||||
|
extension_number=125, |
||||||
|
), |
||||||
|
), |
||||||
|
reflection_pb2.ServerReflectionRequest( |
||||||
|
file_containing_extension=reflection_pb2.ExtensionRequest( |
||||||
|
containing_type='i.donut.exist.co.uk.org.net.me.name.foo', |
||||||
|
extension_number=55, |
||||||
|
), |
||||||
|
), |
||||||
|
) |
||||||
|
responses = tuple(self._stub.ServerReflectionInfo(requests)) |
||||||
|
expected_responses = ( |
||||||
|
reflection_pb2.ServerReflectionResponse( |
||||||
|
valid_host='', |
||||||
|
file_descriptor_response=reflection_pb2.FileDescriptorResponse( |
||||||
|
file_descriptor_proto=( |
||||||
|
_file_descriptor_to_proto(empty_extensions_pb2.DESCRIPTOR), |
||||||
|
) |
||||||
|
) |
||||||
|
), |
||||||
|
reflection_pb2.ServerReflectionResponse( |
||||||
|
valid_host='', |
||||||
|
error_response=reflection_pb2.ErrorResponse( |
||||||
|
error_code=grpc.StatusCode.NOT_FOUND.value[0], |
||||||
|
error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(), |
||||||
|
) |
||||||
|
), |
||||||
|
) |
||||||
|
self.assertEqual(expected_responses, responses) |
||||||
|
|
||||||
|
def testListServices(self): |
||||||
|
requests = ( |
||||||
|
reflection_pb2.ServerReflectionRequest( |
||||||
|
list_services='', |
||||||
|
), |
||||||
|
) |
||||||
|
responses = tuple(self._stub.ServerReflectionInfo(requests)) |
||||||
|
expected_responses = ( |
||||||
|
reflection_pb2.ServerReflectionResponse( |
||||||
|
valid_host='', |
||||||
|
list_services_response=reflection_pb2.ListServiceResponse( |
||||||
|
service=tuple( |
||||||
|
reflection_pb2.ServiceResponse(name=name) |
||||||
|
for name in _SERVICE_NAMES |
||||||
|
) |
||||||
|
) |
||||||
|
), |
||||||
|
) |
||||||
|
self.assertEqual(expected_responses, responses) |
||||||
|
|
||||||
|
if __name__ == '__main__': |
||||||
|
unittest.main(verbosity=2) |
@ -1,44 +1,49 @@ |
|||||||
[ |
[ |
||||||
"_api_test.AllTest", |
"health_check._health_servicer_test.HealthServicerTest", |
||||||
"_api_test.ChannelConnectivityTest", |
"interop._insecure_interop_test.InsecureInteropTest", |
||||||
"_api_test.ChannelTest", |
"interop._secure_interop_test.SecureInteropTest", |
||||||
"_auth_test.AccessTokenCallCredentialsTest", |
"protoc_plugin._python_plugin_test.PythonPluginTest", |
||||||
"_auth_test.GoogleCallCredentialsTest", |
"protoc_plugin._split_definitions_test.SameCommonTest", |
||||||
"_beta_features_test.BetaFeaturesTest", |
"protoc_plugin._split_definitions_test.SameSeparateTest", |
||||||
"_beta_features_test.ContextManagementAndLifecycleTest", |
"protoc_plugin._split_definitions_test.SplitCommonTest", |
||||||
"_cancel_many_calls_test.CancelManyCallsTest", |
"protoc_plugin._split_definitions_test.SplitSeparateTest", |
||||||
"_channel_args_test.ChannelArgsTest", |
"protoc_plugin.beta_python_plugin_test.PythonPluginTest", |
||||||
"_channel_connectivity_test.ChannelConnectivityTest", |
"reflection._reflection_servicer_test.ReflectionServicerTest", |
||||||
"_channel_ready_future_test.ChannelReadyFutureTest", |
"unit._api_test.AllTest", |
||||||
"_channel_test.ChannelTest", |
"unit._api_test.ChannelConnectivityTest", |
||||||
"_compression_test.CompressionTest", |
"unit._api_test.ChannelTest", |
||||||
"_connectivity_channel_test.ConnectivityStatesTest", |
"unit._auth_test.AccessTokenCallCredentialsTest", |
||||||
"_credentials_test.CredentialsTest", |
"unit._auth_test.GoogleCallCredentialsTest", |
||||||
"_empty_message_test.EmptyMessageTest", |
"unit._channel_args_test.ChannelArgsTest", |
||||||
"_exit_test.ExitTest", |
"unit._channel_connectivity_test.ChannelConnectivityTest", |
||||||
"_face_interface_test.DynamicInvokerBlockingInvocationInlineServiceTest", |
"unit._channel_ready_future_test.ChannelReadyFutureTest", |
||||||
"_face_interface_test.DynamicInvokerFutureInvocationAsynchronousEventServiceTest", |
"unit._compression_test.CompressionTest", |
||||||
"_face_interface_test.GenericInvokerBlockingInvocationInlineServiceTest", |
"unit._credentials_test.CredentialsTest", |
||||||
"_face_interface_test.GenericInvokerFutureInvocationAsynchronousEventServiceTest", |
"unit._cython._cancel_many_calls_test.CancelManyCallsTest", |
||||||
"_face_interface_test.MultiCallableInvokerBlockingInvocationInlineServiceTest", |
"unit._cython._channel_test.ChannelTest", |
||||||
"_face_interface_test.MultiCallableInvokerFutureInvocationAsynchronousEventServiceTest", |
"unit._cython._read_some_but_not_all_responses_test.ReadSomeButNotAllResponsesTest", |
||||||
"_health_servicer_test.HealthServicerTest", |
"unit._cython.cygrpc_test.InsecureServerInsecureClient", |
||||||
"_implementations_test.CallCredentialsTest", |
"unit._cython.cygrpc_test.SecureServerSecureClient", |
||||||
"_implementations_test.ChannelCredentialsTest", |
"unit._cython.cygrpc_test.TypeSmokeTest", |
||||||
"_insecure_interop_test.InsecureInteropTest", |
"unit._empty_message_test.EmptyMessageTest", |
||||||
"_logging_pool_test.LoggingPoolTest", |
"unit._exit_test.ExitTest", |
||||||
"_metadata_code_details_test.MetadataCodeDetailsTest", |
"unit._metadata_code_details_test.MetadataCodeDetailsTest", |
||||||
"_metadata_test.MetadataTest", |
"unit._metadata_test.MetadataTest", |
||||||
"_not_found_test.NotFoundTest", |
"unit._rpc_test.RPCTest", |
||||||
"_python_plugin_test.PythonPluginTest", |
"unit._sanity._sanity_test.Sanity", |
||||||
"_read_some_but_not_all_responses_test.ReadSomeButNotAllResponsesTest", |
"unit._thread_cleanup_test.CleanupThreadTest", |
||||||
"_rpc_test.RPCTest", |
"unit.beta._beta_features_test.BetaFeaturesTest", |
||||||
"_sanity_test.Sanity", |
"unit.beta._beta_features_test.ContextManagementAndLifecycleTest", |
||||||
"_secure_interop_test.SecureInteropTest", |
"unit.beta._connectivity_channel_test.ConnectivityStatesTest", |
||||||
"_thread_cleanup_test.CleanupThreadTest", |
"unit.beta._face_interface_test.DynamicInvokerBlockingInvocationInlineServiceTest", |
||||||
"_utilities_test.ChannelConnectivityTest", |
"unit.beta._face_interface_test.DynamicInvokerFutureInvocationAsynchronousEventServiceTest", |
||||||
"beta_python_plugin_test.PythonPluginTest", |
"unit.beta._face_interface_test.GenericInvokerBlockingInvocationInlineServiceTest", |
||||||
"cygrpc_test.InsecureServerInsecureClient", |
"unit.beta._face_interface_test.GenericInvokerFutureInvocationAsynchronousEventServiceTest", |
||||||
"cygrpc_test.SecureServerSecureClient", |
"unit.beta._face_interface_test.MultiCallableInvokerBlockingInvocationInlineServiceTest", |
||||||
"cygrpc_test.TypeSmokeTest" |
"unit.beta._face_interface_test.MultiCallableInvokerFutureInvocationAsynchronousEventServiceTest", |
||||||
|
"unit.beta._implementations_test.CallCredentialsTest", |
||||||
|
"unit.beta._implementations_test.ChannelCredentialsTest", |
||||||
|
"unit.beta._not_found_test.NotFoundTest", |
||||||
|
"unit.beta._utilities_test.ChannelConnectivityTest", |
||||||
|
"unit.framework.foundation._logging_pool_test.LoggingPoolTest" |
||||||
] |
] |
||||||
|
@ -0,0 +1,34 @@ |
|||||||
|
%YAML 1.2 |
||||||
|
--- | |
||||||
|
# Copyright 2016, Google Inc. |
||||||
|
# All rights reserved. |
||||||
|
# |
||||||
|
# Redistribution and use in source and binary forms, with or without |
||||||
|
# modification, are permitted provided that the following conditions are |
||||||
|
# met: |
||||||
|
# |
||||||
|
# * Redistributions of source code must retain the above copyright |
||||||
|
# notice, this list of conditions and the following disclaimer. |
||||||
|
# * Redistributions in binary form must reproduce the above |
||||||
|
# copyright notice, this list of conditions and the following disclaimer |
||||||
|
# in the documentation and/or other materials provided with the |
||||||
|
# distribution. |
||||||
|
# * Neither the name of Google Inc. nor the names of its |
||||||
|
# contributors may be used to endorse or promote products derived from |
||||||
|
# this software without specific prior written permission. |
||||||
|
# |
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
|
||||||
|
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! |
||||||
|
|
||||||
|
VERSION='${settings.python_version.pep440()}' |
@ -0,0 +1,136 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
*is % allowed in string |
||||||
|
*/ |
||||||
|
|
||||||
|
#include <memory> |
||||||
|
#include <string> |
||||||
|
|
||||||
|
#include <gflags/gflags.h> |
||||||
|
#include <grpc++/grpc++.h> |
||||||
|
#include <grpc/support/log.h> |
||||||
|
#include <grpc/support/port_platform.h> |
||||||
|
|
||||||
|
#include "src/cpp/thread_manager/thread_manager.h" |
||||||
|
#include "test/cpp/util/test_config.h" |
||||||
|
|
||||||
|
namespace grpc { |
||||||
|
class ThreadManagerTest GRPC_FINAL : public grpc::ThreadManager { |
||||||
|
public: |
||||||
|
ThreadManagerTest() |
||||||
|
: ThreadManager(kMinPollers, kMaxPollers), |
||||||
|
num_do_work_(0), |
||||||
|
num_poll_for_work_(0), |
||||||
|
num_work_found_(0) {} |
||||||
|
|
||||||
|
grpc::ThreadManager::WorkStatus PollForWork(void **tag, |
||||||
|
bool *ok) GRPC_OVERRIDE; |
||||||
|
void DoWork(void *tag, bool ok) GRPC_OVERRIDE; |
||||||
|
void PerformTest(); |
||||||
|
|
||||||
|
private: |
||||||
|
void SleepForMs(int sleep_time_ms); |
||||||
|
|
||||||
|
static const int kMinPollers = 2; |
||||||
|
static const int kMaxPollers = 10; |
||||||
|
|
||||||
|
static const int kPollingTimeoutMsec = 10; |
||||||
|
static const int kDoWorkDurationMsec = 1; |
||||||
|
|
||||||
|
// PollForWork will return SHUTDOWN after these many number of invocations
|
||||||
|
static const int kMaxNumPollForWork = 50; |
||||||
|
|
||||||
|
gpr_atm num_do_work_; // Number of calls to DoWork
|
||||||
|
gpr_atm num_poll_for_work_; // Number of calls to PollForWork
|
||||||
|
gpr_atm num_work_found_; // Number of times WORK_FOUND was returned
|
||||||
|
}; |
||||||
|
|
||||||
|
void ThreadManagerTest::SleepForMs(int duration_ms) { |
||||||
|
gpr_timespec sleep_time = |
||||||
|
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), |
||||||
|
gpr_time_from_millis(duration_ms, GPR_TIMESPAN)); |
||||||
|
gpr_sleep_until(sleep_time); |
||||||
|
} |
||||||
|
|
||||||
|
grpc::ThreadManager::WorkStatus ThreadManagerTest::PollForWork(void **tag, |
||||||
|
bool *ok) { |
||||||
|
int call_num = gpr_atm_no_barrier_fetch_add(&num_poll_for_work_, 1); |
||||||
|
|
||||||
|
if (call_num >= kMaxNumPollForWork) { |
||||||
|
Shutdown(); |
||||||
|
return SHUTDOWN; |
||||||
|
} |
||||||
|
|
||||||
|
// Simulate "polling for work" by sleeping for sometime
|
||||||
|
SleepForMs(kPollingTimeoutMsec); |
||||||
|
|
||||||
|
*tag = nullptr; |
||||||
|
*ok = true; |
||||||
|
|
||||||
|
// Return timeout roughly 1 out of every 3 calls
|
||||||
|
if (call_num % 3 == 0) { |
||||||
|
return TIMEOUT; |
||||||
|
} else { |
||||||
|
gpr_atm_no_barrier_fetch_add(&num_work_found_, 1); |
||||||
|
return WORK_FOUND; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void ThreadManagerTest::DoWork(void *tag, bool ok) { |
||||||
|
gpr_atm_no_barrier_fetch_add(&num_do_work_, 1); |
||||||
|
SleepForMs(kDoWorkDurationMsec); // Simulate doing work by sleeping
|
||||||
|
} |
||||||
|
|
||||||
|
void ThreadManagerTest::PerformTest() { |
||||||
|
// Initialize() starts the ThreadManager
|
||||||
|
Initialize(); |
||||||
|
|
||||||
|
// Wait for all the threads to gracefully terminate
|
||||||
|
Wait(); |
||||||
|
|
||||||
|
// The number of times DoWork() was called is equal to the number of times
|
||||||
|
// WORK_FOUND was returned
|
||||||
|
gpr_log(GPR_DEBUG, "DoWork() called %ld times", |
||||||
|
gpr_atm_no_barrier_load(&num_do_work_)); |
||||||
|
GPR_ASSERT(gpr_atm_no_barrier_load(&num_do_work_) == |
||||||
|
gpr_atm_no_barrier_load(&num_work_found_)); |
||||||
|
} |
||||||
|
} // namespace grpc
|
||||||
|
|
||||||
|
int main(int argc, char **argv) { |
||||||
|
std::srand(std::time(NULL)); |
||||||
|
|
||||||
|
grpc::testing::InitTest(&argc, &argv, true); |
||||||
|
grpc::ThreadManagerTest test_rpc_manager; |
||||||
|
test_rpc_manager.PerformTest(); |
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
@ -0,0 +1,201 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\1.0.204.1.props')" /> |
||||||
|
<ItemGroup Label="ProjectConfigurations"> |
||||||
|
<ProjectConfiguration Include="Debug|Win32"> |
||||||
|
<Configuration>Debug</Configuration> |
||||||
|
<Platform>Win32</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
<ProjectConfiguration Include="Debug|x64"> |
||||||
|
<Configuration>Debug</Configuration> |
||||||
|
<Platform>x64</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
<ProjectConfiguration Include="Release|Win32"> |
||||||
|
<Configuration>Release</Configuration> |
||||||
|
<Platform>Win32</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
<ProjectConfiguration Include="Release|x64"> |
||||||
|
<Configuration>Release</Configuration> |
||||||
|
<Platform>x64</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
</ItemGroup> |
||||||
|
<PropertyGroup Label="Globals"> |
||||||
|
<ProjectGuid>{08C611E4-7F87-73BE-76CE-C158A4CC05A3}</ProjectGuid> |
||||||
|
<IgnoreWarnIntDirInTempDetected>true</IgnoreWarnIntDirInTempDetected> |
||||||
|
<IntDir>$(SolutionDir)IntDir\$(MSBuildProjectName)\</IntDir> |
||||||
|
</PropertyGroup> |
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '10.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v100</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v110</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '12.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v120</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '14.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v140</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration"> |
||||||
|
<ConfigurationType>Application</ConfigurationType> |
||||||
|
<UseDebugLibraries>true</UseDebugLibraries> |
||||||
|
<CharacterSet>Unicode</CharacterSet> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration"> |
||||||
|
<ConfigurationType>Application</ConfigurationType> |
||||||
|
<UseDebugLibraries>false</UseDebugLibraries> |
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization> |
||||||
|
<CharacterSet>Unicode</CharacterSet> |
||||||
|
</PropertyGroup> |
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
||||||
|
<ImportGroup Label="ExtensionSettings"> |
||||||
|
</ImportGroup> |
||||||
|
<ImportGroup Label="PropertySheets"> |
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\cpptest.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\global.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\openssl.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\protobuf.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\winsock.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\zlib.props" /> |
||||||
|
</ImportGroup> |
||||||
|
<PropertyGroup Label="UserMacros" /> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> |
||||||
|
<TargetName>thread_manager_test</TargetName> |
||||||
|
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib> |
||||||
|
<Configuration-grpc_dependencies_zlib>Debug</Configuration-grpc_dependencies_zlib> |
||||||
|
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl> |
||||||
|
<Configuration-grpc_dependencies_openssl>Debug</Configuration-grpc_dependencies_openssl> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'"> |
||||||
|
<TargetName>thread_manager_test</TargetName> |
||||||
|
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib> |
||||||
|
<Configuration-grpc_dependencies_zlib>Release</Configuration-grpc_dependencies_zlib> |
||||||
|
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl> |
||||||
|
<Configuration-grpc_dependencies_openssl>Release</Configuration-grpc_dependencies_openssl> |
||||||
|
</PropertyGroup> |
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>Disabled</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>Disabled</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>MaxSpeed</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||||
|
<OptimizeReferences>true</OptimizeReferences> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>MaxSpeed</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||||
|
<OptimizeReferences>true</OptimizeReferences> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<ClCompile Include="$(SolutionDir)\..\test\cpp\thread_manager\thread_manager_test.cc"> |
||||||
|
</ClCompile> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc++\grpc++.vcxproj"> |
||||||
|
<Project>{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}</Project> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc\grpc.vcxproj"> |
||||||
|
<Project>{29D16885-7228-4C31-81ED-5F9187C7F2A9}</Project> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr\gpr.vcxproj"> |
||||||
|
<Project>{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}</Project> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc++_test_config\grpc++_test_config.vcxproj"> |
||||||
|
<Project>{3F7D093D-11F9-C4BC-BEB7-18EB28E3F290}</Project> |
||||||
|
</ProjectReference> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<None Include="packages.config" /> |
||||||
|
</ItemGroup> |
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
||||||
|
<ImportGroup Label="ExtensionTargets"> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" /> |
||||||
|
</ImportGroup> |
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> |
||||||
|
<PropertyGroup> |
||||||
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> |
||||||
|
</PropertyGroup> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" /> |
||||||
|
</Target> |
||||||
|
</Project> |
||||||
|
|
@ -0,0 +1,21 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<ItemGroup> |
||||||
|
<ClCompile Include="$(SolutionDir)\..\test\cpp\thread_manager\thread_manager_test.cc"> |
||||||
|
<Filter>test\cpp\thread_manager</Filter> |
||||||
|
</ClCompile> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<Filter Include="test"> |
||||||
|
<UniqueIdentifier>{e9e471cd-7f7e-9abc-af13-ec58851849ac}</UniqueIdentifier> |
||||||
|
</Filter> |
||||||
|
<Filter Include="test\cpp"> |
||||||
|
<UniqueIdentifier>{b350f72c-af76-7272-4342-1b0fc7a458ee}</UniqueIdentifier> |
||||||
|
</Filter> |
||||||
|
<Filter Include="test\cpp\thread_manager"> |
||||||
|
<UniqueIdentifier>{6b09ea8d-fbc6-e6fe-f884-b3d3dfcbfc12}</UniqueIdentifier> |
||||||
|
</Filter> |
||||||
|
</ItemGroup> |
||||||
|
</Project> |
||||||
|
|
Loading…
Reference in new issue