Merge pull request #2413 from dgquintas/interop_sniffer

Introduced InteropContextInspector
pull/2470/head^2
Craig Tiller 9 years ago
commit eec373c555
  1. 7
      include/grpc++/server_context.h
  2. 2
      src/cpp/server/server_context.cc
  3. 13
      test/cpp/interop/server_helper.cc
  4. 13
      test/cpp/interop/server_helper.h

@ -76,6 +76,10 @@ class CallOpBuffer;
class CompletionQueue;
class Server;
namespace testing {
class InteropContextInspector;
} // namespace testing
// Interface of server side rpc context.
class ServerContext {
public:
@ -93,7 +97,7 @@ class ServerContext {
void AddInitialMetadata(const grpc::string& key, const grpc::string& value);
void AddTrailingMetadata(const grpc::string& key, const grpc::string& value);
bool IsCancelled();
bool IsCancelled() const;
const std::multimap<grpc::string, grpc::string>& client_metadata() {
return client_metadata_;
@ -102,6 +106,7 @@ class ServerContext {
std::shared_ptr<const AuthContext> auth_context() const;
private:
friend class ::grpc::testing::InteropContextInspector;
friend class ::grpc::Server;
template <class W, class R>
friend class ::grpc::ServerAsyncReader;

@ -144,7 +144,7 @@ void ServerContext::AddTrailingMetadata(const grpc::string& key,
trailing_metadata_.insert(std::make_pair(key, value));
}
bool ServerContext::IsCancelled() {
bool ServerContext::IsCancelled() const {
return completion_op_ && completion_op_->CheckCancelled(cq_);
}

@ -58,5 +58,18 @@ std::shared_ptr<ServerCredentials> CreateInteropServerCredentials() {
}
}
InteropContextInspector::InteropContextInspector(
const ::grpc::ServerContext& context)
: context_(context) {}
std::shared_ptr<const AuthContext> InteropContextInspector::GetAuthContext()
const {
return context_.auth_context();
}
bool InteropContextInspector::IsCancelled() const {
return context_.IsCancelled();
}
} // namespace testing
} // namespace grpc

@ -36,6 +36,7 @@
#include <memory>
#include <grpc++/server_context.h>
#include <grpc++/server_credentials.h>
namespace grpc {
@ -43,6 +44,18 @@ namespace testing {
std::shared_ptr<ServerCredentials> CreateInteropServerCredentials();
class InteropContextInspector {
public:
InteropContextInspector(const ::grpc::ServerContext& context);
// Inspector methods, able to peek inside ServerContext, follow.
std::shared_ptr<const AuthContext> GetAuthContext() const;
bool IsCancelled() const;
private:
const ::grpc::ServerContext& context_;
};
} // namespace testing
} // namespace grpc

Loading…
Cancel
Save