forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config: subscription factory dependency injection.
While working on TDS, it became apparent that the xDS subscription tests are a bit conflated today, since they include both testing of the xDS resource specific subscription and also things like the REST fetcher, etc. This is because the subscription factory is a static, rather than a mockable dependency of subscriptions. This PR transforms subscription factory to an instance object. The PR is quite massive, but it has big pay-off in terms of reducing the boiler plate in xDS tests, separating concerns and making it easier to add new xDS types. Given the recent additions of SRDS, VHDS, TDS and FCDS, this seems worth it. A number of xDS tests have been modified to work with the new pattern. Some tests and properties that are orthogonally tested in subscription_factory_test or the gRPC/REST subscription tests are no longer tested in the resource specified tests. Some general absl::string_view goodness plumbing was also needed due to the new string_view-based interface. Risk level: Low Testing: Modified a number of resource specified xDS unit tests. Relates to envoyproxy#6708. Signed-off-by: Harvey Tuch <[email protected]>
- Loading branch information
Showing
77 changed files
with
733 additions
and
1,280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include "envoy/api/api.h" | ||
#include "envoy/api/v2/core/base.pb.h" | ||
#include "envoy/config/subscription.h" | ||
#include "envoy/stats/scope.h" | ||
#include "envoy/upstream/cluster_manager.h" | ||
|
||
namespace Envoy { | ||
namespace Config { | ||
|
||
class SubscriptionFactory { | ||
public: | ||
virtual ~SubscriptionFactory() {} | ||
|
||
/** | ||
* Subscription factory interface. | ||
* | ||
* @param config envoy::api::v2::core::ConfigSource to construct from. | ||
* @param type_url type URL for the resource being subscribed to. | ||
* @param scope stats scope for any stats tracked by the subscription. | ||
* @param callbacks the callbacks needed by all Subscription objects, to deliver config updates. | ||
* The callbacks must not result in the deletion of the Subscription object. | ||
* @return SubscriptionPtr subscription object corresponding for config and type_url. | ||
*/ | ||
virtual SubscriptionPtr | ||
subscriptionFromConfigSource(const envoy::api::v2::core::ConfigSource& config, | ||
absl::string_view type_url, Stats::Scope& scope, | ||
SubscriptionCallbacks& callbacks) PURE; | ||
}; | ||
|
||
} // namespace Config | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#pragma once | ||
|
||
#include "envoy/api/api.h" | ||
#include "envoy/api/v2/core/base.pb.h" | ||
#include "envoy/config/subscription.h" | ||
#include "envoy/config/subscription_factory.h" | ||
#include "envoy/stats/scope.h" | ||
#include "envoy/upstream/cluster_manager.h" | ||
|
||
namespace Envoy { | ||
namespace Config { | ||
|
||
class SubscriptionFactoryImpl : public SubscriptionFactory { | ||
public: | ||
SubscriptionFactoryImpl(const LocalInfo::LocalInfo& local_info, Event::Dispatcher& dispatcher, | ||
Upstream::ClusterManager& cm, Runtime::RandomGenerator& random, | ||
ProtobufMessage::ValidationVisitor& validation_visitor, Api::Api& api); | ||
|
||
// Config::SubscriptionFactory | ||
SubscriptionPtr subscriptionFromConfigSource(const envoy::api::v2::core::ConfigSource& config, | ||
absl::string_view type_url, Stats::Scope& scope, | ||
SubscriptionCallbacks& callbacks) override; | ||
|
||
private: | ||
const LocalInfo::LocalInfo& local_info_; | ||
Event::Dispatcher& dispatcher_; | ||
Upstream::ClusterManager& cm_; | ||
Runtime::RandomGenerator& random_; | ||
ProtobufMessage::ValidationVisitor& validation_visitor_; | ||
Api::Api& api_; | ||
}; | ||
|
||
} // namespace Config | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.