Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: ADS implementation. #1658

Merged
merged 11 commits into from
Sep 20, 2017
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def envoy_api_deps(skip_targets):
"bootstrap",
"discovery",
"cds",
"discovery",
"eds",
"health_check",
"lds",
Expand Down
4 changes: 2 additions & 2 deletions include/envoy/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ load(
envoy_package()

envoy_cc_library(
name = "ads_interface",
hdrs = ["ads.h"],
name = "grpc_mux_interface",
hdrs = ["grpc_mux.h"],
deps = [
"//source/common/protobuf",
],
Expand Down
65 changes: 0 additions & 65 deletions include/envoy/config/ads.h

This file was deleted.

76 changes: 76 additions & 0 deletions include/envoy/config/grpc_mux.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#pragma once

#include "envoy/common/exception.h"
#include "envoy/common/pure.h"

#include "common/protobuf/protobuf.h"

namespace Envoy {
namespace Config {

class GrpcMuxCallbacks {
public:
virtual ~GrpcMuxCallbacks() {}

/**
* Called when a configuration update is received.
* @param resources vector of fetched resources corresponding to the configuration update.
* @param version_info update version.
* @throw EnvoyException with reason if the configuration is rejected. Otherwise the configuration
* is accepted. Accepted configurations have their version_info reflected in subsequent
* requests.
*/
virtual void onConfigUpdate(const Protobuf::RepeatedPtrField<ProtobufWkt::Any>& resources,
const std::string& version_info) PURE;

/**
* Called when either the subscription is unable to fetch a config update or when onConfigUpdate
* invokes an exception.
* @param e supplies any exception data on why the fetch failed. May be nullptr.
*/
virtual void onConfigUpdateFailed(const EnvoyException* e) PURE;
};

/**
* Handle on an muxed gRPC subscription. The subscription is canceled on destruction.
*/
class GrpcMuxWatch {
public:
virtual ~GrpcMuxWatch() {}
};

typedef std::unique_ptr<GrpcMuxWatch> GrpcMuxWatchPtr;

/**
* Manage one or more gRPC subscriptions on a single stream to management server. This can be used
* for a single xDS API, e.g. EDS, or to combined multiple xDS APIs for ADS.
*/
class GrpcMux {
public:
virtual ~GrpcMux() {}

/**
* Initiate stream with management server.
*/
virtual void start() PURE;

/**
* Start a configuration subscription asynchronously for some API type and resources.
* @param type_url type URL corresponding to xDS API, e.g.
* type.googleapis.com/envoy.api.v2.Cluster.
* @param resources vector of resource names to watch for. If this is empty, then all
* resources for type_url will result in callbacks.
* @param callbacks the callbacks to be notified of configuration updates. These must be valid
* until GrpcMuxWatch is destroyed.
* @return GrpcMuxWatchPtr a handle to cancel the subscription with. E.g. when a cluster goes
* away, its EDS updates should be cancelled by destroying the GrpcMuxWatchPtr.
*/
virtual GrpcMuxWatchPtr subscribe(const std::string& type_url,
const std::vector<std::string>& resources,
GrpcMuxCallbacks& callbacks) PURE;
};

typedef std::unique_ptr<GrpcMux> GrpcMuxPtr;

} // namespace Config
} // namespace Envoy
2 changes: 1 addition & 1 deletion include/envoy/upstream/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ envoy_cc_library(
":thread_local_cluster_interface",
":upstream_interface",
"//include/envoy/access_log:access_log_interface",
"//include/envoy/config:ads_interface",
"//include/envoy/config:grpc_mux_interface",
"//include/envoy/http:async_client_interface",
"//include/envoy/http:conn_pool_interface",
"//include/envoy/local_info:local_info_interface",
Expand Down
6 changes: 3 additions & 3 deletions include/envoy/upstream/cluster_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <unordered_map>

#include "envoy/access_log/access_log.h"
#include "envoy/config/ads.h"
#include "envoy/config/grpc_mux.h"
#include "envoy/http/async_client.h"
#include "envoy/http/conn_pool.h"
#include "envoy/local_info/local_info.h"
Expand Down Expand Up @@ -123,9 +123,9 @@ class ClusterManager {
* the management of clusters but instead is required early in ClusterManager/server
* initialization and in various sites that need ClusterManager for xDS API interfacing.
*
* @return AdsApi& ADS API provider referencee.
* @return GrpcMux& ADS API provider referencee.
*/
virtual Config::AdsApi& adsProvider() PURE;
virtual Config::GrpcMux& adsMux() PURE;
};

typedef std::unique_ptr<ClusterManager> ClusterManagerPtr;
Expand Down
77 changes: 47 additions & 30 deletions source/common/config/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,6 @@ envoy_cc_library(
],
)

envoy_cc_library(
name = "ads_api_lib",
hdrs = ["ads_api_impl.h"],
external_deps = ["envoy_discovery"],
deps = [
"//include/envoy/config:ads_interface",
"//include/envoy/config:subscription_interface",
"//include/envoy/upstream:cluster_manager_interface",
],
)

envoy_cc_library(
name = "ads_subscription_lib",
hdrs = ["ads_subscription_impl.h"],
external_deps = ["envoy_discovery"],
deps = [
"//include/envoy/config:ads_interface",
"//include/envoy/config:subscription_interface",
"//source/common/common:assert_lib",
"//source/common/common:logger_lib",
"//source/common/grpc:common_lib",
"//source/common/protobuf",
],
)

envoy_cc_library(
name = "bootstrap_json_lib",
srcs = ["bootstrap_json.cc"],
Expand Down Expand Up @@ -129,18 +104,47 @@ envoy_cc_library(
)

envoy_cc_library(
name = "grpc_subscription_lib",
hdrs = ["grpc_subscription_impl.h"],
external_deps = ["envoy_base"],
name = "grpc_mux_lib",
srcs = ["grpc_mux_impl.cc"],
hdrs = ["grpc_mux_impl.h"],
external_deps = ["envoy_discovery"],
deps = [
":utility_lib",
"//include/envoy/config:grpc_mux_interface",
"//include/envoy/config:subscription_interface",
"//include/envoy/upstream:cluster_manager_interface",
"//source/common/common:logger_lib",
"//source/common/config:utility_lib",
"//source/common/grpc:async_client_lib",
"//source/common/protobuf",
],
)

envoy_cc_library(
name = "grpc_mux_subscription_lib",
hdrs = ["grpc_mux_subscription_impl.h"],
external_deps = ["envoy_discovery"],
deps = [
"//include/envoy/config:grpc_mux_interface",
"//include/envoy/config:subscription_interface",
"//source/common/common:assert_lib",
"//source/common/common:logger_lib",
"//source/common/grpc:common_lib",
"//source/common/protobuf",
],
)

envoy_cc_library(
name = "grpc_subscription_lib",
hdrs = ["grpc_subscription_impl.h"],
external_deps = ["envoy_base"],
deps = [
":grpc_mux_lib",
":grpc_mux_subscription_lib",
"//include/envoy/config:subscription_interface",
"//include/envoy/event:dispatcher_interface",
],
)

envoy_cc_library(
name = "http_subscription_lib",
hdrs = ["http_subscription_impl.h"],
Expand Down Expand Up @@ -209,6 +213,12 @@ envoy_cc_library(
],
)

envoy_cc_library(
name = "resources_lib",
hdrs = ["resources.h"],
deps = ["//source/common/common:singleton"],
)

envoy_cc_library(
name = "rds_json_lib",
srcs = ["rds_json.cc"],
Expand All @@ -230,8 +240,8 @@ envoy_cc_library(
hdrs = ["subscription_factory.h"],
external_deps = ["envoy_base"],
deps = [
":ads_subscription_lib",
":filesystem_subscription_lib",
":grpc_mux_subscription_lib",
":grpc_subscription_lib",
":http_subscription_lib",
":utility_lib",
Expand All @@ -258,10 +268,16 @@ envoy_cc_library(
hdrs = ["utility.h"],
external_deps = [
"envoy_base",
"envoy_cds",
"envoy_eds",
"envoy_lds",
"envoy_rds",
"envoy_filter_http_connection_manager",
],
deps = [
":json_utility_lib",
":resources_lib",
"//include/envoy/config:grpc_mux_interface",
"//include/envoy/config:subscription_interface",
"//include/envoy/local_info:local_info_interface",
"//include/envoy/registry",
Expand All @@ -270,6 +286,7 @@ envoy_cc_library(
"//source/common/common:hash_lib",
"//source/common/common:hex_lib",
"//source/common/common:singleton",
"//source/common/grpc:common_lib",
"//source/common/json:config_schemas_lib",
"//source/common/protobuf",
"//source/common/protobuf:utility_lib",
Expand Down
37 changes: 0 additions & 37 deletions source/common/config/ads_api_impl.h

This file was deleted.

Loading