Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions include/envoy/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ envoy_package()
envoy_cc_library(
name = "subscription_interface",
hdrs = ["subscription.h"],
external_deps = ["protobuf"],
deps = ["//include/envoy/stats:stats_macros"],
deps = [
"//include/envoy/stats:stats_macros",
"//source/common/protobuf",
],
)
4 changes: 2 additions & 2 deletions include/envoy/config/subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#include "envoy/common/pure.h"
#include "envoy/stats/stats_macros.h"

#include "google/protobuf/repeated_field.h"
#include "common/protobuf/protobuf.h"

namespace Envoy {
namespace Config {

template <class ResourceType> class SubscriptionCallbacks {
public:
typedef google::protobuf::RepeatedPtrField<ResourceType> ResourceVector;
typedef Protobuf::RepeatedPtrField<ResourceType> ResourceVector;

virtual ~SubscriptionCallbacks() {}

Expand Down
4 changes: 2 additions & 2 deletions include/envoy/grpc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ envoy_package()
envoy_cc_library(
name = "async_client_interface",
hdrs = ["async_client.h"],
external_deps = ["protobuf"],
deps = [
":status",
"//include/envoy/common:optional",
"//include/envoy/http:header_map_interface",
"//source/common/protobuf",
],
)

envoy_cc_library(
name = "rpc_channel_interface",
hdrs = ["rpc_channel.h"],
external_deps = ["protobuf"],
deps = [
"//include/envoy/common:optional",
"//include/envoy/http:header_map_interface",
"//source/common/protobuf",
],
)

Expand Down
4 changes: 2 additions & 2 deletions include/envoy/grpc/async_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "envoy/grpc/status.h"
#include "envoy/http/header_map.h"

#include "google/protobuf/descriptor.h"
#include "common/protobuf/protobuf.h"

namespace Envoy {
namespace Grpc {
Expand Down Expand Up @@ -104,7 +104,7 @@ template <class RequestType, class ResponseType> class AsyncClient {
* be reclaimed.
*/
virtual AsyncClientStream<RequestType>*
start(const google::protobuf::MethodDescriptor& service_method,
start(const Protobuf::MethodDescriptor& service_method,
AsyncClientCallbacks<ResponseType>& callbacks,
const Optional<std::chrono::milliseconds>& timeout) PURE;
};
Expand Down
14 changes: 7 additions & 7 deletions include/envoy/grpc/rpc_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "envoy/common/pure.h"
#include "envoy/http/header_map.h"

#include "google/protobuf/service.h"
#include "common/protobuf/protobuf.h"

namespace Envoy {
namespace Grpc {
Expand Down Expand Up @@ -42,14 +42,14 @@ class RpcChannelCallbacks {

/**
* A single active grpc request arbiter. This interface derives from
* ::google::protobuf::RpcChannel. When mocking, CallMethod() can be overriden to accept the
* response message and the mock constructor can accept a RequestCallbacks object. An RpcChannel
* should be passed to the constructor of an RPC stub generated via protoc using the "option
* cc_generic_services = true;" option. It can be used for multiple service calls, but not
* concurrently.
* Protobuf::RpcChannel. When mocking, CallMethod() can be overriden to accept
* the response message and the mock constructor can accept a RequestCallbacks
* object. An RpcChannel should be passed to the constructor of an RPC stub
* generated via protoc using the "option cc_generic_services = true;" option.
* It can be used for multiple service calls, but not concurrently.
* DEPRECATED: See https://github.com/lyft/envoy/issues/1102
*/
class RpcChannel : public ::google::protobuf::RpcChannel {
class RpcChannel : public Protobuf::RpcChannel {
public:
virtual ~RpcChannel() {}

Expand Down
2 changes: 1 addition & 1 deletion source/common/buffer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ envoy_cc_library(
name = "zero_copy_input_stream_lib",
srcs = ["zero_copy_input_stream_impl.cc"],
hdrs = ["zero_copy_input_stream_impl.h"],
external_deps = ["protobuf"],
deps = [
":buffer_lib",
"//source/common/protobuf",
],
)
8 changes: 4 additions & 4 deletions source/common/buffer/zero_copy_input_stream_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

#include "envoy/buffer/buffer.h"

#include "google/protobuf/io/zero_copy_stream.h"
#include "common/protobuf/protobuf.h"

namespace Envoy {

namespace Buffer {

class ZeroCopyInputStreamImpl : public virtual google::protobuf::io::ZeroCopyInputStream {
class ZeroCopyInputStreamImpl : public virtual Protobuf::io::ZeroCopyInputStream {
public:
// Create input stream with one buffer, and finish immediately
ZeroCopyInputStreamImpl(Buffer::InstancePtr&& buffer);
Expand All @@ -26,7 +26,7 @@ class ZeroCopyInputStreamImpl : public virtual google::protobuf::io::ZeroCopyInp
// Mark the stream is finished
void finish() { finished_ = true; }

// google::protobuf::io::ZeroCopyInputStream
// Protobuf::io::ZeroCopyInputStream
// See
// https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.zero_copy_stream#ZeroCopyInputStream
// for each method details.
Expand All @@ -37,7 +37,7 @@ class ZeroCopyInputStreamImpl : public virtual google::protobuf::io::ZeroCopyInp
virtual bool Next(const void** data, int* size) override;
virtual void BackUp(int count) override;
virtual bool Skip(int count) override; // Not implemented
virtual google::protobuf::int64 ByteCount() const override { return byte_count_; }
virtual int64_t ByteCount() const override { return byte_count_; }

protected:
Buffer::InstancePtr buffer_;
Expand Down
11 changes: 9 additions & 2 deletions source/common/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ envoy_package()
envoy_cc_library(
name = "filesystem_subscription_lib",
hdrs = ["filesystem_subscription_impl.h"],
external_deps = ["protobuf"],
deps = [
"//include/envoy/config:subscription_interface",
"//include/envoy/event:dispatcher_interface",
"//include/envoy/filesystem:filesystem_interface",
"//source/common/common:logger_lib",
"//source/common/config:utility_lib",
"//source/common/filesystem:filesystem_lib",
"//source/common/protobuf",
],
)

Expand All @@ -31,6 +31,7 @@ envoy_cc_library(
"//source/common/common:logger_lib",
"//source/common/config:utility_lib",
"//source/common/grpc:async_client_lib",
"//source/common/protobuf",
],
)

Expand All @@ -48,6 +49,7 @@ envoy_cc_library(
"//source/common/config:utility_lib",
"//source/common/http:headers_lib",
"//source/common/http:rest_api_fetcher_lib",
"//source/common/protobuf",
],
)

Expand All @@ -61,6 +63,7 @@ envoy_cc_library(
":http_subscription_lib",
":utility_lib",
"//include/envoy/config:subscription_interface",
"//source/common/protobuf",
],
)

Expand All @@ -69,7 +72,10 @@ envoy_cc_library(
srcs = ["metadata.cc"],
hdrs = ["metadata.h"],
external_deps = ["envoy_base"],
deps = ["//source/common/common:singleton"],
deps = [
"//source/common/common:singleton",
"//source/common/protobuf",
],
)

envoy_cc_library(
Expand All @@ -80,5 +86,6 @@ envoy_cc_library(
deps = [
"//include/envoy/config:subscription_interface",
"//include/envoy/upstream:cluster_manager_interface",
"//source/common/protobuf",
],
)
10 changes: 6 additions & 4 deletions source/common/config/filesystem_subscription_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#include "common/common/macros.h"
#include "common/config/utility.h"
#include "common/filesystem/filesystem_impl.h"
#include "common/protobuf/protobuf.h"

#include "api/base.pb.h"
#include "google/protobuf/util/json_util.h"

namespace Envoy {
namespace Config {
Expand Down Expand Up @@ -55,10 +55,12 @@ class FilesystemSubscriptionImpl : public Config::Subscription<ResourceType>,
try {
const std::string json = Filesystem::fileReadToEnd(path_);
envoy::api::v2::DiscoveryResponse message;
const auto status = google::protobuf::util::JsonStringToMessage(json, &message);
if (status != google::protobuf::util::Status::OK) {
const auto status =
Protobuf::util::JsonStringToMessage(ProtobufTypes::ToString(json), &message);
if (!status.ok()) {
callbacks_->onConfigUpdateFailed(nullptr);
ENVOY_LOG(warn, "Filesystem config JSON conversion error: {}", status.ToString());
ENVOY_LOG(warn, "Filesystem config JSON conversion error: {}",
ProtobufTypes::FromString(status.ToString()));
stats_.update_failure_.inc();
return;
}
Expand Down
37 changes: 19 additions & 18 deletions source/common/config/grpc_subscription_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "common/common/logger.h"
#include "common/config/utility.h"
#include "common/grpc/async_client_impl.h"
#include "common/protobuf/protobuf.h"

#include "api/base.pb.h"

Expand All @@ -19,8 +20,7 @@ class GrpcSubscriptionImpl : public Config::Subscription<ResourceType>,
public:
GrpcSubscriptionImpl(const envoy::api::v2::Node& node, Upstream::ClusterManager& cm,
const std::string& remote_cluster_name, Event::Dispatcher& dispatcher,
const google::protobuf::MethodDescriptor& service_method,
SubscriptionStats stats)
const Protobuf::MethodDescriptor& service_method, SubscriptionStats stats)
: GrpcSubscriptionImpl(
node,
std::unique_ptr<Grpc::AsyncClientImpl<envoy::api::v2::DiscoveryRequest,
Expand All @@ -30,13 +30,12 @@ class GrpcSubscriptionImpl : public Config::Subscription<ResourceType>,
remote_cluster_name)),
dispatcher, service_method, stats) {}

GrpcSubscriptionImpl(
const envoy::api::v2::Node& node,
std::unique_ptr<
Grpc::AsyncClient<envoy::api::v2::DiscoveryRequest, envoy::api::v2::DiscoveryResponse>>
async_client,
Event::Dispatcher& dispatcher, const google::protobuf::MethodDescriptor& service_method,
SubscriptionStats stats)
GrpcSubscriptionImpl(const envoy::api::v2::Node& node,
std::unique_ptr<Grpc::AsyncClient<envoy::api::v2::DiscoveryRequest,
envoy::api::v2::DiscoveryResponse>>
async_client,
Event::Dispatcher& dispatcher,
const Protobuf::MethodDescriptor& service_method, SubscriptionStats stats)
: async_client_(std::move(async_client)), service_method_(service_method),
retry_timer_(dispatcher.createTimer([this]() -> void { establishNewStream(); })),
stats_(stats) {
Expand All @@ -46,7 +45,8 @@ class GrpcSubscriptionImpl : public Config::Subscription<ResourceType>,
void setRetryTimer() { retry_timer_->enableTimer(std::chrono::milliseconds(RETRY_DELAY_MS)); }

void establishNewStream() {
ENVOY_LOG(debug, "Establishing new gRPC bidi stream for {}", service_method_.DebugString());
ENVOY_LOG(debug, "Establishing new gRPC bidi stream for {}",
ProtobufTypes::FromString(service_method_.DebugString()));
stats_.update_attempt_.inc();
stream_ = async_client_->start(service_method_, *this, Optional<std::chrono::milliseconds>());
if (stream_ == nullptr) {
Expand All @@ -68,16 +68,16 @@ class GrpcSubscriptionImpl : public Config::Subscription<ResourceType>,
void start(const std::vector<std::string>& resources,
Config::SubscriptionCallbacks<ResourceType>& callbacks) override {
ASSERT(callbacks_ == nullptr);
google::protobuf::RepeatedPtrField<std::string> resources_vector(resources.begin(),
resources.end());
Protobuf::RepeatedPtrField<ProtobufTypes::String> resources_vector(resources.begin(),
resources.end());
request_.mutable_resource_names()->Swap(&resources_vector);
callbacks_ = &callbacks;
establishNewStream();
}

void updateResources(const std::vector<std::string>& resources) override {
google::protobuf::RepeatedPtrField<std::string> resources_vector(resources.begin(),
resources.end());
Protobuf::RepeatedPtrField<ProtobufTypes::String> resources_vector(resources.begin(),
resources.end());
request_.mutable_resource_names()->Swap(&resources_vector);
sendDiscoveryRequest();
}
Expand All @@ -95,15 +95,16 @@ class GrpcSubscriptionImpl : public Config::Subscription<ResourceType>,
const auto typed_resources = Config::Utility::getTypedResources<ResourceType>(*message);
try {
callbacks_->onConfigUpdate(typed_resources);
request_.set_version_info(message->version_info());
request_.set_version_info(ProtobufTypes::FromString(message->version_info()));
stats_.update_success_.inc();
} catch (const EnvoyException& e) {
ENVOY_LOG(warn, "gRPC config update rejected: {}", e.what());
stats_.update_rejected_.inc();
callbacks_->onConfigUpdateFailed(&e);
}
// This effectively ACK/NACKs the accepted configuration.
ENVOY_LOG(debug, "Sending version update: {}", message->version_info());
ENVOY_LOG(debug, "Sending version update: {}",
ProtobufTypes::FromString(message->version_info()));
stats_.update_attempt_.inc();
sendDiscoveryRequest();
}
Expand Down Expand Up @@ -131,9 +132,9 @@ class GrpcSubscriptionImpl : public Config::Subscription<ResourceType>,
std::unique_ptr<
Grpc::AsyncClient<envoy::api::v2::DiscoveryRequest, envoy::api::v2::DiscoveryResponse>>
async_client_;
const google::protobuf::MethodDescriptor& service_method_;
const Protobuf::MethodDescriptor& service_method_;
Event::TimerPtr retry_timer_;
google::protobuf::RepeatedPtrField<std::string> resources_;
Protobuf::RepeatedPtrField<ProtobufTypes::String> resources_;
Config::SubscriptionCallbacks<ResourceType>* callbacks_{};
Grpc::AsyncClientStream<envoy::api::v2::DiscoveryRequest>* stream_{};
envoy::api::v2::DiscoveryRequest request_;
Expand Down
Loading