mirror of https://github.com/grpc/grpc.git
commit
b55c88aa55
30 changed files with 1473 additions and 80 deletions
@ -0,0 +1,62 @@ |
||||
/*
|
||||
* |
||||
* 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 GRPCXX_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H |
||||
#define GRPCXX_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H |
||||
|
||||
#include <memory> |
||||
|
||||
#include <grpc++/health_check_service_interface.h> |
||||
#include <grpc++/impl/server_builder_option.h> |
||||
#include <grpc++/support/config.h> |
||||
|
||||
namespace grpc { |
||||
|
||||
class HealthCheckServiceServerBuilderOption : public ServerBuilderOption { |
||||
public: |
||||
// The ownership of hc will be taken and transferred to the grpc server.
|
||||
// To explicitly disable default service, pass in a nullptr.
|
||||
explicit HealthCheckServiceServerBuilderOption( |
||||
std::unique_ptr<HealthCheckServiceInterface> hc); |
||||
~HealthCheckServiceServerBuilderOption() override {} |
||||
void UpdateArguments(ChannelArguments* args) override; |
||||
void UpdatePlugins( |
||||
std::vector<std::unique_ptr<ServerBuilderPlugin>>* plugins) override; |
||||
|
||||
private: |
||||
std::unique_ptr<HealthCheckServiceInterface> hc_; |
||||
}; |
||||
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCXX_EXT_HEALTH_CHECK_SERVICE_SERVER_BUILDER_OPTION_H
|
@ -0,0 +1,166 @@ |
||||
/*
|
||||
* |
||||
* 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 <memory> |
||||
#include <mutex> |
||||
|
||||
#include <grpc++/impl/codegen/method_handler_impl.h> |
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/cpp/server/health/default_health_check_service.h" |
||||
#include "src/cpp/server/health/health.pb.h" |
||||
#include "third_party/nanopb/pb_decode.h" |
||||
#include "third_party/nanopb/pb_encode.h" |
||||
|
||||
namespace grpc { |
||||
namespace { |
||||
const char kHealthCheckMethodName[] = "/grpc.health.v1.Health/Check"; |
||||
} // namespace
|
||||
|
||||
DefaultHealthCheckService::HealthCheckServiceImpl::HealthCheckServiceImpl( |
||||
DefaultHealthCheckService* service) |
||||
: service_(service), method_(nullptr) { |
||||
MethodHandler* handler = |
||||
new RpcMethodHandler<HealthCheckServiceImpl, ByteBuffer, ByteBuffer>( |
||||
std::mem_fn(&HealthCheckServiceImpl::Check), this); |
||||
method_ = new RpcServiceMethod(kHealthCheckMethodName, RpcMethod::NORMAL_RPC, |
||||
handler); |
||||
AddMethod(method_); |
||||
} |
||||
|
||||
Status DefaultHealthCheckService::HealthCheckServiceImpl::Check( |
||||
ServerContext* context, const ByteBuffer* request, ByteBuffer* response) { |
||||
// Decode request.
|
||||
std::vector<Slice> slices; |
||||
request->Dump(&slices); |
||||
uint8_t* request_bytes = nullptr; |
||||
bool request_bytes_owned = false; |
||||
size_t request_size = 0; |
||||
grpc_health_v1_HealthCheckRequest request_struct; |
||||
if (slices.empty()) { |
||||
request_struct.has_service = false; |
||||
} else if (slices.size() == 1) { |
||||
request_bytes = const_cast<uint8_t*>(slices[0].begin()); |
||||
request_size = slices[0].size(); |
||||
} else { |
||||
request_bytes_owned = true; |
||||
request_bytes = static_cast<uint8_t*>(gpr_malloc(request->Length())); |
||||
uint8_t* copy_to = request_bytes; |
||||
for (size_t i = 0; i < slices.size(); i++) { |
||||
memcpy(copy_to, slices[i].begin(), slices[i].size()); |
||||
copy_to += slices[i].size(); |
||||
} |
||||
} |
||||
|
||||
if (request_bytes != nullptr) { |
||||
pb_istream_t istream = pb_istream_from_buffer(request_bytes, request_size); |
||||
bool decode_status = pb_decode( |
||||
&istream, grpc_health_v1_HealthCheckRequest_fields, &request_struct); |
||||
if (request_bytes_owned) { |
||||
gpr_free(request_bytes); |
||||
} |
||||
if (!decode_status) { |
||||
return Status(StatusCode::INVALID_ARGUMENT, ""); |
||||
} |
||||
} |
||||
|
||||
// Check status from the associated default health checking service.
|
||||
DefaultHealthCheckService::ServingStatus serving_status = |
||||
service_->GetServingStatus( |
||||
request_struct.has_service ? request_struct.service : ""); |
||||
if (serving_status == DefaultHealthCheckService::NOT_FOUND) { |
||||
return Status(StatusCode::NOT_FOUND, ""); |
||||
} |
||||
|
||||
// Encode response
|
||||
grpc_health_v1_HealthCheckResponse response_struct; |
||||
response_struct.has_status = true; |
||||
response_struct.status = |
||||
serving_status == DefaultHealthCheckService::SERVING |
||||
? grpc_health_v1_HealthCheckResponse_ServingStatus_SERVING |
||||
: grpc_health_v1_HealthCheckResponse_ServingStatus_NOT_SERVING; |
||||
pb_ostream_t ostream; |
||||
memset(&ostream, 0, sizeof(ostream)); |
||||
pb_encode(&ostream, grpc_health_v1_HealthCheckResponse_fields, |
||||
&response_struct); |
||||
grpc_slice response_slice = grpc_slice_malloc(ostream.bytes_written); |
||||
ostream = pb_ostream_from_buffer(GRPC_SLICE_START_PTR(response_slice), |
||||
GRPC_SLICE_LENGTH(response_slice)); |
||||
bool encode_status = pb_encode( |
||||
&ostream, grpc_health_v1_HealthCheckResponse_fields, &response_struct); |
||||
if (!encode_status) { |
||||
return Status(StatusCode::INTERNAL, "Failed to encode response."); |
||||
} |
||||
Slice encoded_response(response_slice, Slice::STEAL_REF); |
||||
ByteBuffer response_buffer(&encoded_response, 1); |
||||
response->Swap(&response_buffer); |
||||
return Status::OK; |
||||
} |
||||
|
||||
DefaultHealthCheckService::DefaultHealthCheckService() { |
||||
services_map_.emplace("", true); |
||||
} |
||||
|
||||
void DefaultHealthCheckService::SetServingStatus( |
||||
const grpc::string& service_name, bool serving) { |
||||
std::lock_guard<std::mutex> lock(mu_); |
||||
services_map_[service_name] = serving; |
||||
} |
||||
|
||||
void DefaultHealthCheckService::SetServingStatus(bool serving) { |
||||
std::lock_guard<std::mutex> lock(mu_); |
||||
for (auto iter = services_map_.begin(); iter != services_map_.end(); ++iter) { |
||||
iter->second = serving; |
||||
} |
||||
} |
||||
|
||||
DefaultHealthCheckService::ServingStatus |
||||
DefaultHealthCheckService::GetServingStatus( |
||||
const grpc::string& service_name) const { |
||||
std::lock_guard<std::mutex> lock(mu_); |
||||
const auto& iter = services_map_.find(service_name); |
||||
if (iter == services_map_.end()) { |
||||
return NOT_FOUND; |
||||
} |
||||
return iter->second ? SERVING : NOT_SERVING; |
||||
} |
||||
|
||||
DefaultHealthCheckService::HealthCheckServiceImpl* |
||||
DefaultHealthCheckService::GetHealthCheckService() { |
||||
GPR_ASSERT(impl_ == nullptr); |
||||
impl_.reset(new HealthCheckServiceImpl(this)); |
||||
return impl_.get(); |
||||
} |
||||
|
||||
} // namespace grpc
|
@ -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. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_INTERNAL_CPP_SERVER_DEFAULT_HEALTH_CHECK_SERVICE_H |
||||
#define GRPC_INTERNAL_CPP_SERVER_DEFAULT_HEALTH_CHECK_SERVICE_H |
||||
|
||||
#include <mutex> |
||||
|
||||
#include <grpc++/health_check_service_interface.h> |
||||
#include <grpc++/impl/codegen/service_type.h> |
||||
#include <grpc++/support/byte_buffer.h> |
||||
|
||||
namespace grpc { |
||||
|
||||
// Default implementation of HealthCheckServiceInterface. Server will create and
|
||||
// own it.
|
||||
class DefaultHealthCheckService final : public HealthCheckServiceInterface { |
||||
public: |
||||
// The service impl to register with the server.
|
||||
class HealthCheckServiceImpl : public Service { |
||||
public: |
||||
explicit HealthCheckServiceImpl(DefaultHealthCheckService* service); |
||||
|
||||
Status Check(ServerContext* context, const ByteBuffer* request, |
||||
ByteBuffer* response); |
||||
|
||||
private: |
||||
const DefaultHealthCheckService* const service_; |
||||
RpcServiceMethod* method_; |
||||
}; |
||||
|
||||
DefaultHealthCheckService(); |
||||
void SetServingStatus(const grpc::string& service_name, |
||||
bool serving) override; |
||||
void SetServingStatus(bool serving) override; |
||||
enum ServingStatus { NOT_FOUND, SERVING, NOT_SERVING }; |
||||
ServingStatus GetServingStatus(const grpc::string& service_name) const; |
||||
HealthCheckServiceImpl* GetHealthCheckService(); |
||||
|
||||
private: |
||||
mutable std::mutex mu_; |
||||
std::map<grpc::string, bool> services_map_; |
||||
std::unique_ptr<HealthCheckServiceImpl> impl_; |
||||
}; |
||||
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPC_INTERNAL_CPP_SERVER_DEFAULT_HEALTH_CHECK_SERVICE_H
|
@ -0,0 +1,24 @@ |
||||
/* Automatically generated nanopb constant definitions */ |
||||
/* Generated by nanopb-0.3.7-dev */ |
||||
|
||||
#include "src/cpp/server/health/health.pb.h" |
||||
|
||||
/* @@protoc_insertion_point(includes) */ |
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
|
||||
|
||||
const pb_field_t grpc_health_v1_HealthCheckRequest_fields[2] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, grpc_health_v1_HealthCheckRequest, service, service, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t grpc_health_v1_HealthCheckResponse_fields[2] = { |
||||
PB_FIELD( 1, UENUM , OPTIONAL, STATIC , FIRST, grpc_health_v1_HealthCheckResponse, status, status, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
|
||||
/* @@protoc_insertion_point(eof) */ |
@ -0,0 +1,72 @@ |
||||
/* Automatically generated nanopb header */ |
||||
/* Generated by nanopb-0.3.7-dev */ |
||||
|
||||
#ifndef PB_GRPC_HEALTH_V1_HEALTH_PB_H_INCLUDED |
||||
#define PB_GRPC_HEALTH_V1_HEALTH_PB_H_INCLUDED |
||||
#include "third_party/nanopb/pb.h" |
||||
/* @@protoc_insertion_point(includes) */ |
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Enum definitions */ |
||||
typedef enum _grpc_health_v1_HealthCheckResponse_ServingStatus { |
||||
grpc_health_v1_HealthCheckResponse_ServingStatus_UNKNOWN = 0, |
||||
grpc_health_v1_HealthCheckResponse_ServingStatus_SERVING = 1, |
||||
grpc_health_v1_HealthCheckResponse_ServingStatus_NOT_SERVING = 2 |
||||
} grpc_health_v1_HealthCheckResponse_ServingStatus; |
||||
#define _grpc_health_v1_HealthCheckResponse_ServingStatus_MIN grpc_health_v1_HealthCheckResponse_ServingStatus_UNKNOWN |
||||
#define _grpc_health_v1_HealthCheckResponse_ServingStatus_MAX grpc_health_v1_HealthCheckResponse_ServingStatus_NOT_SERVING |
||||
#define _grpc_health_v1_HealthCheckResponse_ServingStatus_ARRAYSIZE ((grpc_health_v1_HealthCheckResponse_ServingStatus)(grpc_health_v1_HealthCheckResponse_ServingStatus_NOT_SERVING+1)) |
||||
|
||||
/* Struct definitions */ |
||||
typedef struct _grpc_health_v1_HealthCheckRequest { |
||||
bool has_service; |
||||
char service[200]; |
||||
/* @@protoc_insertion_point(struct:grpc_health_v1_HealthCheckRequest) */ |
||||
} grpc_health_v1_HealthCheckRequest; |
||||
|
||||
typedef struct _grpc_health_v1_HealthCheckResponse { |
||||
bool has_status; |
||||
grpc_health_v1_HealthCheckResponse_ServingStatus status; |
||||
/* @@protoc_insertion_point(struct:grpc_health_v1_HealthCheckResponse) */ |
||||
} grpc_health_v1_HealthCheckResponse; |
||||
|
||||
/* Default values for struct fields */ |
||||
|
||||
/* Initializer values for message structs */ |
||||
#define grpc_health_v1_HealthCheckRequest_init_default {false, ""} |
||||
#define grpc_health_v1_HealthCheckResponse_init_default {false, (grpc_health_v1_HealthCheckResponse_ServingStatus)0} |
||||
#define grpc_health_v1_HealthCheckRequest_init_zero {false, ""} |
||||
#define grpc_health_v1_HealthCheckResponse_init_zero {false, (grpc_health_v1_HealthCheckResponse_ServingStatus)0} |
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */ |
||||
#define grpc_health_v1_HealthCheckRequest_service_tag 1 |
||||
#define grpc_health_v1_HealthCheckResponse_status_tag 1 |
||||
|
||||
/* Struct field encoding specification for nanopb */ |
||||
extern const pb_field_t grpc_health_v1_HealthCheckRequest_fields[2]; |
||||
extern const pb_field_t grpc_health_v1_HealthCheckResponse_fields[2]; |
||||
|
||||
/* Maximum encoded size of messages (where known) */ |
||||
#define grpc_health_v1_HealthCheckRequest_size 203 |
||||
#define grpc_health_v1_HealthCheckResponse_size 2 |
||||
|
||||
/* Message IDs (where set with "msgid" option) */ |
||||
#ifdef PB_MSGID |
||||
|
||||
#define HEALTH_MESSAGES \ |
||||
|
||||
|
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
} /* extern "C" */ |
||||
#endif |
||||
/* @@protoc_insertion_point(eof) */ |
||||
|
||||
#endif |
@ -0,0 +1,49 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include <grpc++/health_check_service_interface.h> |
||||
|
||||
namespace grpc { |
||||
namespace { |
||||
bool g_grpc_default_health_check_service_enabled = false; |
||||
} // namesapce
|
||||
|
||||
bool DefaultHealthCheckServiceEnabled() { |
||||
return g_grpc_default_health_check_service_enabled; |
||||
} |
||||
|
||||
void EnableDefaultHealthCheckService(bool enable) { |
||||
g_grpc_default_health_check_service_enabled = enable; |
||||
} |
||||
|
||||
} // namespace grpc
|
@ -0,0 +1,50 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include <grpc++/ext/health_check_service_server_builder_option.h> |
||||
|
||||
namespace grpc { |
||||
|
||||
HealthCheckServiceServerBuilderOption::HealthCheckServiceServerBuilderOption( |
||||
std::unique_ptr<HealthCheckServiceInterface> hc) |
||||
: hc_(std::move(hc)) {} |
||||
// Hand over hc_ to the server.
|
||||
void HealthCheckServiceServerBuilderOption::UpdateArguments( |
||||
ChannelArguments* args) { |
||||
args->SetPointer(kHealthCheckServiceInterfaceArg, hc_.release()); |
||||
} |
||||
|
||||
void HealthCheckServiceServerBuilderOption::UpdatePlugins( |
||||
std::vector<std::unique_ptr<ServerBuilderPlugin>>* plugins) {} |
||||
|
||||
} // namespace grpc
|
@ -0,0 +1 @@ |
||||
grpc.health.v1.HealthCheckRequest.service max_size:200 |
@ -0,0 +1,323 @@ |
||||
/*
|
||||
* |
||||
* 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 <memory> |
||||
#include <mutex> |
||||
#include <thread> |
||||
#include <vector> |
||||
|
||||
#include <grpc++/channel.h> |
||||
#include <grpc++/client_context.h> |
||||
#include <grpc++/create_channel.h> |
||||
#include <grpc++/ext/health_check_service_server_builder_option.h> |
||||
#include <grpc++/health_check_service_interface.h> |
||||
#include <grpc++/server.h> |
||||
#include <grpc++/server_builder.h> |
||||
#include <grpc++/server_context.h> |
||||
#include <grpc/grpc.h> |
||||
#include <grpc/support/log.h> |
||||
#include <gtest/gtest.h> |
||||
|
||||
#include "src/proto/grpc/health/v1/health.grpc.pb.h" |
||||
#include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" |
||||
#include "src/proto/grpc/testing/echo.grpc.pb.h" |
||||
#include "test/core/util/port.h" |
||||
#include "test/core/util/test_config.h" |
||||
#include "test/cpp/end2end/test_service_impl.h" |
||||
|
||||
using grpc::health::v1::Health; |
||||
using grpc::health::v1::HealthCheckRequest; |
||||
using grpc::health::v1::HealthCheckResponse; |
||||
|
||||
namespace grpc { |
||||
namespace testing { |
||||
namespace { |
||||
|
||||
// A sample sync implementation of the health checking service. This does the
|
||||
// same thing as the default one.
|
||||
class HealthCheckServiceImpl : public ::grpc::health::v1::Health::Service { |
||||
public: |
||||
Status Check(ServerContext* context, const HealthCheckRequest* request, |
||||
HealthCheckResponse* response) override { |
||||
std::lock_guard<std::mutex> lock(mu_); |
||||
auto iter = status_map_.find(request->service()); |
||||
if (iter == status_map_.end()) { |
||||
return Status(StatusCode::NOT_FOUND, ""); |
||||
} |
||||
response->set_status(iter->second); |
||||
return Status::OK; |
||||
} |
||||
|
||||
void SetStatus(const grpc::string& service_name, |
||||
HealthCheckResponse::ServingStatus status) { |
||||
std::lock_guard<std::mutex> lock(mu_); |
||||
status_map_[service_name] = status; |
||||
} |
||||
|
||||
void SetAll(HealthCheckResponse::ServingStatus status) { |
||||
std::lock_guard<std::mutex> lock(mu_); |
||||
for (auto iter = status_map_.begin(); iter != status_map_.end(); ++iter) { |
||||
iter->second = status; |
||||
} |
||||
} |
||||
|
||||
private: |
||||
std::mutex mu_; |
||||
std::map<const grpc::string, HealthCheckResponse::ServingStatus> status_map_; |
||||
}; |
||||
|
||||
// A custom implementation of the health checking service interface. This is
|
||||
// used to test that it prevents the server from creating a default service and
|
||||
// also serves as an example of how to override the default service.
|
||||
class CustomHealthCheckService : public HealthCheckServiceInterface { |
||||
public: |
||||
explicit CustomHealthCheckService(HealthCheckServiceImpl* impl) |
||||
: impl_(impl) { |
||||
impl_->SetStatus("", HealthCheckResponse::SERVING); |
||||
} |
||||
void SetServingStatus(const grpc::string& service_name, |
||||
bool serving) override { |
||||
impl_->SetStatus(service_name, serving ? HealthCheckResponse::SERVING |
||||
: HealthCheckResponse::NOT_SERVING); |
||||
} |
||||
|
||||
void SetServingStatus(bool serving) override { |
||||
impl_->SetAll(serving ? HealthCheckResponse::SERVING |
||||
: HealthCheckResponse::NOT_SERVING); |
||||
} |
||||
|
||||
private: |
||||
HealthCheckServiceImpl* impl_; // not owned
|
||||
}; |
||||
|
||||
void LoopCompletionQueue(ServerCompletionQueue* cq) { |
||||
void* tag; |
||||
bool ok; |
||||
while (cq->Next(&tag, &ok)) { |
||||
abort(); // Nothing should come out of the cq.
|
||||
} |
||||
} |
||||
|
||||
class HealthServiceEnd2endTest : public ::testing::Test { |
||||
protected: |
||||
HealthServiceEnd2endTest() {} |
||||
|
||||
void SetUpServer(bool register_sync_test_service, bool add_async_cq, |
||||
bool explicit_health_service, |
||||
std::unique_ptr<HealthCheckServiceInterface> service) { |
||||
int port = grpc_pick_unused_port_or_die(); |
||||
server_address_ << "localhost:" << port; |
||||
|
||||
bool register_sync_health_service_impl = |
||||
explicit_health_service && service != nullptr; |
||||
|
||||
// Setup server
|
||||
ServerBuilder builder; |
||||
if (explicit_health_service) { |
||||
std::unique_ptr<ServerBuilderOption> option( |
||||
new HealthCheckServiceServerBuilderOption(std::move(service))); |
||||
builder.SetOption(std::move(option)); |
||||
} |
||||
builder.AddListeningPort(server_address_.str(), |
||||
grpc::InsecureServerCredentials()); |
||||
if (register_sync_test_service) { |
||||
// Register a sync service.
|
||||
builder.RegisterService(&echo_test_service_); |
||||
} |
||||
if (register_sync_health_service_impl) { |
||||
builder.RegisterService(&health_check_service_impl_); |
||||
} |
||||
if (add_async_cq) { |
||||
cq_ = builder.AddCompletionQueue(); |
||||
} |
||||
server_ = builder.BuildAndStart(); |
||||
} |
||||
|
||||
void TearDown() override { |
||||
if (server_) { |
||||
server_->Shutdown(); |
||||
if (cq_ != nullptr) { |
||||
cq_->Shutdown(); |
||||
} |
||||
if (cq_thread_.joinable()) { |
||||
cq_thread_.join(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void ResetStubs() { |
||||
std::shared_ptr<Channel> channel = |
||||
CreateChannel(server_address_.str(), InsecureChannelCredentials()); |
||||
hc_stub_ = grpc::health::v1::Health::NewStub(channel); |
||||
} |
||||
|
||||
// When the expected_status is NOT OK, we do not care about the response.
|
||||
void SendHealthCheckRpc(const grpc::string& service_name, |
||||
const Status& expected_status) { |
||||
EXPECT_FALSE(expected_status.ok()); |
||||
SendHealthCheckRpc(service_name, expected_status, |
||||
HealthCheckResponse::UNKNOWN); |
||||
} |
||||
|
||||
void SendHealthCheckRpc( |
||||
const grpc::string& service_name, const Status& expected_status, |
||||
HealthCheckResponse::ServingStatus expected_serving_status) { |
||||
HealthCheckRequest request; |
||||
request.set_service(service_name); |
||||
HealthCheckResponse response; |
||||
ClientContext context; |
||||
Status s = hc_stub_->Check(&context, request, &response); |
||||
EXPECT_EQ(expected_status.error_code(), s.error_code()); |
||||
if (s.ok()) { |
||||
EXPECT_EQ(expected_serving_status, response.status()); |
||||
} |
||||
} |
||||
|
||||
void VerifyHealthCheckService() { |
||||
HealthCheckServiceInterface* service = server_->GetHealthCheckService(); |
||||
EXPECT_TRUE(service != nullptr); |
||||
const grpc::string kHealthyService("healthy_service"); |
||||
const grpc::string kUnhealthyService("unhealthy_service"); |
||||
const grpc::string kNotRegisteredService("not_registered"); |
||||
service->SetServingStatus(kHealthyService, true); |
||||
service->SetServingStatus(kUnhealthyService, false); |
||||
|
||||
ResetStubs(); |
||||
|
||||
SendHealthCheckRpc("", Status::OK, HealthCheckResponse::SERVING); |
||||
SendHealthCheckRpc(kHealthyService, Status::OK, |
||||
HealthCheckResponse::SERVING); |
||||
SendHealthCheckRpc(kUnhealthyService, Status::OK, |
||||
HealthCheckResponse::NOT_SERVING); |
||||
SendHealthCheckRpc(kNotRegisteredService, |
||||
Status(StatusCode::NOT_FOUND, "")); |
||||
|
||||
service->SetServingStatus(false); |
||||
SendHealthCheckRpc("", Status::OK, HealthCheckResponse::NOT_SERVING); |
||||
SendHealthCheckRpc(kHealthyService, Status::OK, |
||||
HealthCheckResponse::NOT_SERVING); |
||||
SendHealthCheckRpc(kUnhealthyService, Status::OK, |
||||
HealthCheckResponse::NOT_SERVING); |
||||
SendHealthCheckRpc(kNotRegisteredService, |
||||
Status(StatusCode::NOT_FOUND, "")); |
||||
} |
||||
|
||||
TestServiceImpl echo_test_service_; |
||||
HealthCheckServiceImpl health_check_service_impl_; |
||||
std::unique_ptr<Health::Stub> hc_stub_; |
||||
std::unique_ptr<ServerCompletionQueue> cq_; |
||||
std::unique_ptr<Server> server_; |
||||
std::ostringstream server_address_; |
||||
std::thread cq_thread_; |
||||
}; |
||||
|
||||
TEST_F(HealthServiceEnd2endTest, DefaultHealthServiceDisabled) { |
||||
EnableDefaultHealthCheckService(false); |
||||
EXPECT_FALSE(DefaultHealthCheckServiceEnabled()); |
||||
SetUpServer(true, false, false, nullptr); |
||||
HealthCheckServiceInterface* default_service = |
||||
server_->GetHealthCheckService(); |
||||
EXPECT_TRUE(default_service == nullptr); |
||||
|
||||
ResetStubs(); |
||||
|
||||
SendHealthCheckRpc("", Status(StatusCode::UNIMPLEMENTED, "")); |
||||
} |
||||
|
||||
TEST_F(HealthServiceEnd2endTest, DefaultHealthService) { |
||||
EnableDefaultHealthCheckService(true); |
||||
EXPECT_TRUE(DefaultHealthCheckServiceEnabled()); |
||||
SetUpServer(true, false, false, nullptr); |
||||
VerifyHealthCheckService(); |
||||
|
||||
// The default service has a size limit of the service name.
|
||||
const grpc::string kTooLongServiceName(201, 'x'); |
||||
SendHealthCheckRpc(kTooLongServiceName, |
||||
Status(StatusCode::INVALID_ARGUMENT, "")); |
||||
} |
||||
|
||||
// The server has no sync service.
|
||||
TEST_F(HealthServiceEnd2endTest, DefaultHealthServiceAsyncOnly) { |
||||
EnableDefaultHealthCheckService(true); |
||||
EXPECT_TRUE(DefaultHealthCheckServiceEnabled()); |
||||
SetUpServer(false, true, false, nullptr); |
||||
cq_thread_ = std::thread(LoopCompletionQueue, cq_.get()); |
||||
|
||||
HealthCheckServiceInterface* default_service = |
||||
server_->GetHealthCheckService(); |
||||
EXPECT_TRUE(default_service == nullptr); |
||||
|
||||
ResetStubs(); |
||||
|
||||
SendHealthCheckRpc("", Status(StatusCode::UNIMPLEMENTED, "")); |
||||
} |
||||
|
||||
// Provide an empty service to disable the default service.
|
||||
TEST_F(HealthServiceEnd2endTest, ExplicitlyDisableViaOverride) { |
||||
EnableDefaultHealthCheckService(true); |
||||
EXPECT_TRUE(DefaultHealthCheckServiceEnabled()); |
||||
std::unique_ptr<HealthCheckServiceInterface> empty_service; |
||||
SetUpServer(true, false, true, std::move(empty_service)); |
||||
HealthCheckServiceInterface* service = server_->GetHealthCheckService(); |
||||
EXPECT_TRUE(service == nullptr); |
||||
|
||||
ResetStubs(); |
||||
|
||||
SendHealthCheckRpc("", Status(StatusCode::UNIMPLEMENTED, "")); |
||||
} |
||||
|
||||
// Provide an explicit override of health checking service interface.
|
||||
TEST_F(HealthServiceEnd2endTest, ExplicitlyOverride) { |
||||
EnableDefaultHealthCheckService(true); |
||||
EXPECT_TRUE(DefaultHealthCheckServiceEnabled()); |
||||
std::unique_ptr<HealthCheckServiceInterface> override_service( |
||||
new CustomHealthCheckService(&health_check_service_impl_)); |
||||
HealthCheckServiceInterface* underlying_service = override_service.get(); |
||||
SetUpServer(false, false, true, std::move(override_service)); |
||||
HealthCheckServiceInterface* service = server_->GetHealthCheckService(); |
||||
EXPECT_TRUE(service == underlying_service); |
||||
|
||||
ResetStubs(); |
||||
|
||||
VerifyHealthCheckService(); |
||||
} |
||||
|
||||
} // namespace
|
||||
} // namespace testing
|
||||
} // namespace grpc
|
||||
|
||||
int main(int argc, char** argv) { |
||||
grpc_test_init(argc, argv); |
||||
::testing::InitGoogleTest(&argc, argv); |
||||
return RUN_ALL_TESTS(); |
||||
} |
@ -0,0 +1,207 @@ |
||||
<?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>{3EB2B3E9-8BC3-8DF7-82CB-38462FFE5919}</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>health_service_end2end_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>health_service_end2end_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\end2end\health_service_end2end_test.cc"> |
||||
</ClCompile> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc++_test_util\grpc++_test_util.vcxproj"> |
||||
<Project>{0BE77741-552A-929B-A497-4EF7ECE17A64}</Project> |
||||
</ProjectReference> |
||||
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc_test_util\grpc_test_util.vcxproj"> |
||||
<Project>{17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}</Project> |
||||
</ProjectReference> |
||||
<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_test_util\gpr_test_util.vcxproj"> |
||||
<Project>{EAB0A629-17A9-44DB-B5FF-E91A721FE037}</Project> |
||||
</ProjectReference> |
||||
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr\gpr.vcxproj"> |
||||
<Project>{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}</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\end2end\health_service_end2end_test.cc"> |
||||
<Filter>test\cpp\end2end</Filter> |
||||
</ClCompile> |
||||
</ItemGroup> |
||||
|
||||
<ItemGroup> |
||||
<Filter Include="test"> |
||||
<UniqueIdentifier>{00d750b2-db02-2106-d9b7-1d3b2ca58604}</UniqueIdentifier> |
||||
</Filter> |
||||
<Filter Include="test\cpp"> |
||||
<UniqueIdentifier>{02e29b2f-d68a-4474-8483-621ecfd7fa9d}</UniqueIdentifier> |
||||
</Filter> |
||||
<Filter Include="test\cpp\end2end"> |
||||
<UniqueIdentifier>{b0de697a-d73a-23e1-c9af-fa0edf011d4d}</UniqueIdentifier> |
||||
</Filter> |
||||
</ItemGroup> |
||||
</Project> |
||||
|
Loading…
Reference in new issue