Line data Source code
1 : #pragma once
2 :
3 : #include <chrono>
4 : #include <functional>
5 : #include <memory>
6 : #include <string>
7 :
8 : #include "envoy/access_log/access_log.h"
9 : #include "envoy/api/api.h"
10 : #include "envoy/common/random_generator.h"
11 : #include "envoy/config/bootstrap/v3/bootstrap.pb.h"
12 : #include "envoy/config/cluster/v3/cluster.pb.h"
13 : #include "envoy/config/core/v3/address.pb.h"
14 : #include "envoy/config/core/v3/config_source.pb.h"
15 : #include "envoy/config/core/v3/protocol.pb.h"
16 : #include "envoy/config/eds_resources_cache.h"
17 : #include "envoy/config/grpc_mux.h"
18 : #include "envoy/config/subscription_factory.h"
19 : #include "envoy/grpc/async_client_manager.h"
20 : #include "envoy/http/conn_pool.h"
21 : #include "envoy/http/persistent_quic_info.h"
22 : #include "envoy/local_info/local_info.h"
23 : #include "envoy/runtime/runtime.h"
24 : #include "envoy/secret/secret_manager.h"
25 : #include "envoy/server/admin.h"
26 : #include "envoy/server/options.h"
27 : #include "envoy/singleton/manager.h"
28 : #include "envoy/ssl/context_manager.h"
29 : #include "envoy/stats/store.h"
30 : #include "envoy/tcp/conn_pool.h"
31 : #include "envoy/thread_local/thread_local.h"
32 : #include "envoy/upstream/health_checker.h"
33 : #include "envoy/upstream/load_balancer.h"
34 : #include "envoy/upstream/thread_local_cluster.h"
35 : #include "envoy/upstream/upstream.h"
36 :
37 : #include "absl/container/flat_hash_set.h"
38 : #include "absl/container/node_hash_map.h"
39 :
40 : namespace Envoy {
41 : namespace Upstream {
42 :
43 : /**
44 : * ClusterUpdateCallbacks provide a way to expose Cluster lifecycle events in the
45 : * ClusterManager.
46 : */
47 : using ThreadLocalClusterCommand = std::function<ThreadLocalCluster&()>;
48 : class ClusterUpdateCallbacks {
49 : public:
50 223 : virtual ~ClusterUpdateCallbacks() = default;
51 :
52 : /**
53 : * onClusterAddOrUpdate is called when a new cluster is added or an existing cluster
54 : * is updated in the ClusterManager.
55 : * @param cluster_name the name of the changed cluster.
56 : * @param get_cluster is a callable that will provide the ThreadLocalCluster that represents the
57 : * updated cluster. It should be used within the call or discarded.
58 : */
59 : virtual void onClusterAddOrUpdate(absl::string_view cluster_name,
60 : ThreadLocalClusterCommand& get_cluster) PURE;
61 : /**
62 : * onClusterRemoval is called when a cluster is removed; the argument is the cluster name.
63 : * @param cluster_name is the name of the removed cluster.
64 : */
65 : virtual void onClusterRemoval(const std::string& cluster_name) PURE;
66 : };
67 :
68 : /**
69 : * ClusterUpdateCallbacksHandle is a RAII wrapper for a ClusterUpdateCallbacks. Deleting
70 : * the ClusterUpdateCallbacksHandle will remove the callbacks from ClusterManager in O(1).
71 : */
72 : class ClusterUpdateCallbacksHandle {
73 : public:
74 223 : virtual ~ClusterUpdateCallbacksHandle() = default;
75 : };
76 :
77 : using ClusterUpdateCallbacksHandlePtr = std::unique_ptr<ClusterUpdateCallbacksHandle>;
78 :
79 : /**
80 : * Status enum for the result of an attempted cluster discovery.
81 : */
82 : enum class ClusterDiscoveryStatus {
83 : /**
84 : * The discovery process timed out. This means that we haven't yet received any reply from
85 : * on-demand CDS about it.
86 : */
87 : Timeout,
88 : /**
89 : * The discovery process has concluded and on-demand CDS has no such cluster.
90 : */
91 : Missing,
92 : /**
93 : * Cluster found and currently available through ClusterManager.
94 : */
95 : Available,
96 : };
97 :
98 : /**
99 : * ClusterDiscoveryCallback is a callback called at the end of the on-demand cluster discovery
100 : * process. The status of the discovery is sent as a parameter.
101 : */
102 : using ClusterDiscoveryCallback = std::function<void(ClusterDiscoveryStatus)>;
103 : using ClusterDiscoveryCallbackPtr = std::unique_ptr<ClusterDiscoveryCallback>;
104 :
105 : /**
106 : * ClusterDiscoveryCallbackHandle is a RAII wrapper for a ClusterDiscoveryCallback. Deleting the
107 : * ClusterDiscoveryCallbackHandle will remove the callbacks from ClusterManager.
108 : */
109 : class ClusterDiscoveryCallbackHandle {
110 : public:
111 0 : virtual ~ClusterDiscoveryCallbackHandle() = default;
112 : };
113 :
114 : using ClusterDiscoveryCallbackHandlePtr = std::unique_ptr<ClusterDiscoveryCallbackHandle>;
115 :
116 : /**
117 : * A handle to an on-demand CDS.
118 : */
119 : class OdCdsApiHandle {
120 : public:
121 0 : virtual ~OdCdsApiHandle() = default;
122 :
123 : /**
124 : * Request an on-demand discovery of a cluster with a passed name. This ODCDS may be used to
125 : * perform the discovery process in the main thread if there is no discovery going on for this
126 : * cluster. When the requested cluster is added and warmed up, the passed callback will be invoked
127 : * in the same thread that invoked this function.
128 : *
129 : * The returned handle can be destroyed to prevent the callback from being invoked. Note that the
130 : * handle can only be destroyed in the same thread that invoked the function. Destroying the
131 : * handle might not stop the discovery process, though. As soon as the callback is invoked,
132 : * destroying the handle does nothing. It is a responsibility of the caller to make sure that the
133 : * objects captured in the callback outlive the callback.
134 : *
135 : * This function is thread-safe.
136 : *
137 : * @param name is the name of the cluster to be discovered.
138 : * @param callback will be called when the discovery is finished.
139 : * @param timeout describes how long the operation may take before failing.
140 : * @return the discovery process handle.
141 : */
142 : virtual ClusterDiscoveryCallbackHandlePtr
143 : requestOnDemandClusterDiscovery(absl::string_view name, ClusterDiscoveryCallbackPtr callback,
144 : std::chrono::milliseconds timeout) PURE;
145 : };
146 :
147 : using OdCdsApiHandlePtr = std::unique_ptr<OdCdsApiHandle>;
148 :
149 : class ClusterManagerFactory;
150 :
151 : // These are per-cluster per-thread, so not "global" stats.
152 : struct ClusterConnectivityState {
153 223 : ~ClusterConnectivityState() {
154 223 : ASSERT(pending_streams_ == 0);
155 223 : ASSERT(active_streams_ == 0);
156 223 : ASSERT(connecting_and_connected_stream_capacity_ == 0);
157 223 : }
158 :
159 752 : template <class T> void checkAndDecrement(T& value, uint32_t delta) {
160 752 : ASSERT(std::numeric_limits<T>::min() + delta <= value);
161 752 : value -= delta;
162 752 : }
163 :
164 581 : template <class T> void checkAndIncrement(T& value, uint32_t delta) {
165 581 : ASSERT(std::numeric_limits<T>::max() - delta >= value);
166 581 : value += delta;
167 581 : }
168 :
169 173 : void incrPendingStreams(uint32_t delta) { checkAndIncrement(pending_streams_, delta); }
170 175 : void decrPendingStreams(uint32_t delta) { checkAndDecrement(pending_streams_, delta); }
171 206 : void incrConnectingAndConnectedStreamCapacity(uint32_t delta) {
172 206 : checkAndIncrement(connecting_and_connected_stream_capacity_, delta);
173 206 : }
174 375 : void decrConnectingAndConnectedStreamCapacity(uint32_t delta) {
175 375 : checkAndDecrement(connecting_and_connected_stream_capacity_, delta);
176 375 : }
177 202 : void incrActiveStreams(uint32_t delta) { checkAndIncrement(active_streams_, delta); }
178 202 : void decrActiveStreams(uint32_t delta) { checkAndDecrement(active_streams_, delta); }
179 :
180 : // Tracks the number of pending streams for this ClusterManager.
181 : uint32_t pending_streams_{};
182 : // Tracks the number of active streams for this ClusterManager.
183 : uint32_t active_streams_{};
184 : // Tracks the available stream capacity if all connecting connections were connected.
185 : //
186 : // For example, if an H2 connection is started with concurrent stream limit of 100, this
187 : // goes up by 100. If the connection is established and 2 streams are in use, it
188 : // would be reduced to 98 (as 2 of the 100 are not available).
189 : //
190 : // Note that if more HTTP/2 streams have been established than are allowed by
191 : // a late-received SETTINGS frame, this MAY BE NEGATIVE.
192 : // Note this tracks the sum of multiple 32 bit stream capacities so must remain 64 bit.
193 : int64_t connecting_and_connected_stream_capacity_{};
194 : };
195 :
196 : /**
197 : * Manages connection pools and load balancing for upstream clusters. The cluster manager is
198 : * persistent and shared among multiple ongoing requests/connections.
199 : * Cluster manager is initialized in two phases. In the first phase which begins at the construction
200 : * all primary clusters (i.e. with endpoint assignments provisioned statically in bootstrap,
201 : * discovered through DNS or file based CDS) are initialized. This phase may complete synchronously
202 : * with cluster manager construction iff all clusters are STATIC and without health checks
203 : * configured. At the completion of the first phase cluster manager invokes callback set through the
204 : * `setPrimaryClustersInitializedCb` method.
205 : * After the first phase has completed the server instance initializes services (i.e. RTDS) needed
206 : * to successfully deploy the rest of dynamic configuration.
207 : * In the second phase all secondary clusters (with endpoint assignments provisioned by xDS servers)
208 : * are initialized and then the rest of the configuration provisioned through xDS.
209 : */
210 : class ClusterManager {
211 : public:
212 : using PrimaryClustersReadyCallback = std::function<void()>;
213 : using InitializationCompleteCallback = std::function<void()>;
214 :
215 317 : virtual ~ClusterManager() = default;
216 :
217 : /**
218 : * Add or update a cluster via API. The semantics of this API are:
219 : * 1) The hash of the config is used to determine if an already existing cluster has changed.
220 : * Nothing is done if the hash matches the previously running configuration.
221 : * 2) Statically defined clusters (those present when Envoy starts) can not be updated via API.
222 : *
223 : * @param cluster supplies the cluster configuration.
224 : * @param version_info supplies the xDS version of the cluster.
225 : * @return true if the action results in an add/update of a cluster.
226 : */
227 : virtual bool addOrUpdateCluster(const envoy::config::cluster::v3::Cluster& cluster,
228 : const std::string& version_info) PURE;
229 :
230 : /**
231 : * Set a callback that will be invoked when all primary clusters have been initialized.
232 : */
233 : virtual void setPrimaryClustersInitializedCb(PrimaryClustersReadyCallback callback) PURE;
234 :
235 : /**
236 : * Set a callback that will be invoked when all owned clusters have been initialized.
237 : */
238 : virtual void setInitializedCb(InitializationCompleteCallback callback) PURE;
239 :
240 : /**
241 : * Start initialization of secondary clusters and then dynamically configured clusters.
242 : * The "initialized callback" set in the method above is invoked when secondary and
243 : * dynamically provisioned clusters have finished initializing.
244 : */
245 : virtual absl::Status
246 : initializeSecondaryClusters(const envoy::config::bootstrap::v3::Bootstrap& bootstrap) PURE;
247 :
248 : using ClusterInfoMap = absl::flat_hash_map<std::string, std::reference_wrapper<const Cluster>>;
249 : struct ClusterInfoMaps {
250 1069 : bool hasCluster(absl::string_view cluster) const {
251 1069 : return active_clusters_.find(cluster) != active_clusters_.end() ||
252 1069 : warming_clusters_.find(cluster) != warming_clusters_.end();
253 1069 : }
254 :
255 0 : ClusterConstOptRef getCluster(absl::string_view cluster) const {
256 0 : auto active_cluster = active_clusters_.find(cluster);
257 0 : if (active_cluster != active_clusters_.cend()) {
258 0 : return active_cluster->second;
259 0 : }
260 0 : auto warming_cluster = warming_clusters_.find(cluster);
261 0 : if (warming_cluster != warming_clusters_.cend()) {
262 0 : return warming_cluster->second;
263 0 : }
264 0 : return absl::nullopt;
265 0 : }
266 :
267 : ClusterInfoMap active_clusters_;
268 : ClusterInfoMap warming_clusters_;
269 :
270 : // Number of clusters that were dynamically added via API (xDS). This will be
271 : // less than or equal to the number of `active_clusters_` and `warming_clusters_`.
272 : uint32_t added_via_api_clusters_num_{0};
273 : };
274 :
275 : /**
276 : * @return ClusterInfoMap all current clusters including active and warming.
277 : *
278 : * NOTE: This method is only thread safe on the main thread. It should not be called elsewhere.
279 : */
280 : virtual ClusterInfoMaps clusters() const PURE;
281 :
282 : using ClusterSet = absl::flat_hash_set<std::string>;
283 :
284 : /**
285 : * @return const ClusterSet& providing the cluster names that are eligible as
286 : * xDS API config sources. These must be static (i.e. in the
287 : * bootstrap) and non-EDS.
288 : */
289 : virtual const ClusterSet& primaryClusters() PURE;
290 :
291 : /**
292 : * @return ThreadLocalCluster* the thread local cluster with the given name or nullptr if it
293 : * does not exist. This is thread safe.
294 : *
295 : * NOTE: The pointer returned by this function is ONLY safe to use in the context of the owning
296 : * call (or if the caller knows that the cluster is fully static and will never be deleted). In
297 : * the case of dynamic clusters, subsequent event loop iterations may invalidate this pointer.
298 : * If information about the cluster needs to be kept, use the ThreadLocalCluster::info() method to
299 : * obtain cluster information that is safe to store.
300 : *
301 : * NOTE: This method may return nullptr even if the cluster exists (if it hasn't been warmed yet,
302 : * propagated to workers, etc.). Use clusters() for general configuration checking on the main
303 : * thread.
304 : */
305 : virtual ThreadLocalCluster* getThreadLocalCluster(absl::string_view cluster) PURE;
306 :
307 : /**
308 : * Remove a cluster via API. Only clusters added via addOrUpdateCluster() can
309 : * be removed in this manner. Statically defined clusters present when Envoy starts cannot be
310 : * removed.
311 : *
312 : * @return true if the action results in the removal of a cluster.
313 : */
314 : virtual bool removeCluster(const std::string& cluster) PURE;
315 :
316 : /**
317 : * Shutdown the cluster manager prior to destroying connection pools and other thread local data.
318 : */
319 : virtual void shutdown() PURE;
320 :
321 : /**
322 : * @return whether the shutdown method has been called.
323 : */
324 : virtual bool isShutdown() PURE;
325 :
326 : /**
327 : * @return cluster manager wide bind configuration for new upstream connections.
328 : */
329 : virtual const absl::optional<envoy::config::core::v3::BindConfig>& bindConfig() const PURE;
330 :
331 : /**
332 : * Returns a shared_ptr to the singleton xDS-over-gRPC provider for upstream control plane muxing
333 : * of xDS. This is treated somewhat as a special case in ClusterManager, since it does not relate
334 : * logically to the management of clusters but instead is required early in ClusterManager/server
335 : * initialization and in various sites that need ClusterManager for xDS API interfacing.
336 : *
337 : * @return GrpcMux& ADS API provider referencee.
338 : */
339 : virtual Config::GrpcMuxSharedPtr adsMux() PURE;
340 :
341 : /**
342 : * @return Grpc::AsyncClientManager& the cluster manager's gRPC client manager.
343 : */
344 : virtual Grpc::AsyncClientManager& grpcAsyncClientManager() PURE;
345 :
346 : /**
347 : * Return the local cluster name, if it was configured.
348 : *
349 : * @return absl::optional<std::string> the local cluster name, or empty if no local cluster was
350 : * configured.
351 : */
352 : virtual const absl::optional<std::string>& localClusterName() const PURE;
353 :
354 : /**
355 : * This method allows to register callbacks for cluster lifecycle events in the ClusterManager.
356 : * The callbacks will be registered in a thread local slot and the callbacks will be executed
357 : * on the thread that registered them.
358 : * To be executed on all threads, Callbacks need to be registered on all threads.
359 : *
360 : * @param callbacks are the ClusterUpdateCallbacks to add or remove to the cluster manager.
361 : * @return ClusterUpdateCallbacksHandlePtr a RAII that needs to be deleted to
362 : * unregister the callback.
363 : */
364 : virtual ClusterUpdateCallbacksHandlePtr
365 : addThreadLocalClusterUpdateCallbacks(ClusterUpdateCallbacks& callbacks) PURE;
366 :
367 : /**
368 : * Return the factory to use for creating cluster manager related objects.
369 : */
370 : virtual ClusterManagerFactory& clusterManagerFactory() PURE;
371 :
372 : /**
373 : * Obtain the subscription factory for the cluster manager. Since subscriptions may have an
374 : * upstream component, the factory is a facet of the cluster manager.
375 : *
376 : * @return Config::SubscriptionFactory& the subscription factory.
377 : */
378 : virtual Config::SubscriptionFactory& subscriptionFactory() PURE;
379 :
380 : /**
381 : * Returns a struct with all the Stats::StatName objects needed by
382 : * Clusters. This helps factor out some relatively heavy name
383 : * construction which occur when there is a large CDS update during operation,
384 : * relative to recreating all stats from strings on-the-fly.
385 : *
386 : * @return the stat names.
387 : */
388 : virtual const ClusterTrafficStatNames& clusterStatNames() const PURE;
389 : virtual const ClusterConfigUpdateStatNames& clusterConfigUpdateStatNames() const PURE;
390 : virtual const ClusterLbStatNames& clusterLbStatNames() const PURE;
391 : virtual const ClusterEndpointStatNames& clusterEndpointStatNames() const PURE;
392 : virtual const ClusterLoadReportStatNames& clusterLoadReportStatNames() const PURE;
393 : virtual const ClusterCircuitBreakersStatNames& clusterCircuitBreakersStatNames() const PURE;
394 : virtual const ClusterRequestResponseSizeStatNames&
395 : clusterRequestResponseSizeStatNames() const PURE;
396 : virtual const ClusterTimeoutBudgetStatNames& clusterTimeoutBudgetStatNames() const PURE;
397 :
398 : /**
399 : * Predicate function used in drainConnections().
400 : * @param host supplies the host that is about to be drained.
401 : * @return true if the host should be drained, and false otherwise.
402 : *
403 : * IMPORTANT: This predicate must be completely self contained and thread safe. It will be posted
404 : * to all worker threads and run concurrently.
405 : */
406 : using DrainConnectionsHostPredicate = std::function<bool(const Host&)>;
407 :
408 : /**
409 : * Drain all connection pool connections owned by this cluster.
410 : * @param cluster, the cluster to drain.
411 : * @param predicate supplies the optional drain connections host predicate. If not supplied, all
412 : * hosts are drained.
413 : */
414 : virtual void drainConnections(const std::string& cluster,
415 : DrainConnectionsHostPredicate predicate) PURE;
416 :
417 : /**
418 : * Drain all connection pool connections owned by all clusters in the cluster manager.
419 : * @param predicate supplies the optional drain connections host predicate. If not supplied, all
420 : * hosts are drained.
421 : */
422 : virtual void drainConnections(DrainConnectionsHostPredicate predicate) PURE;
423 :
424 : /**
425 : * Check if the cluster is active and statically configured, and if not, return an error
426 : * @param cluster, the cluster to check.
427 : */
428 : virtual absl::Status checkActiveStaticCluster(const std::string& cluster) PURE;
429 :
430 : /**
431 : * Allocates an on-demand CDS API provider from configuration proto or locator.
432 : *
433 : * @param odcds_config is a configuration proto. Used when odcds_resources_locator is a nullopt.
434 : * @param odcds_resources_locator is a locator for ODCDS. Used over odcds_config if not a nullopt.
435 : * @param validation_visitor
436 : * @return OdCdsApiHandlePtr the ODCDS handle.
437 : */
438 : virtual OdCdsApiHandlePtr
439 : allocateOdCdsApi(const envoy::config::core::v3::ConfigSource& odcds_config,
440 : OptRef<xds::core::v3::ResourceLocator> odcds_resources_locator,
441 : ProtobufMessage::ValidationVisitor& validation_visitor) PURE;
442 :
443 : /**
444 : * @param common_lb_config The config field to be stored
445 : * @return shared_ptr to the CommonLbConfig
446 : */
447 : virtual std::shared_ptr<const envoy::config::cluster::v3::Cluster::CommonLbConfig>
448 : getCommonLbConfigPtr(
449 : const envoy::config::cluster::v3::Cluster::CommonLbConfig& common_lb_config) PURE;
450 :
451 : /**
452 : * Returns an EdsResourcesCache that is unique for the cluster manager.
453 : */
454 : virtual Config::EdsResourcesCacheOptRef edsResourcesCache() PURE;
455 : };
456 :
457 : using ClusterManagerPtr = std::unique_ptr<ClusterManager>;
458 :
459 : /**
460 : * Abstract interface for a CDS API provider.
461 : */
462 : class CdsApi {
463 : public:
464 28 : virtual ~CdsApi() = default;
465 :
466 : /**
467 : * Start the first fetch of CDS data.
468 : */
469 : virtual void initialize() PURE;
470 :
471 : /**
472 : * Set a callback that will be called when the CDS API has done an initial load from the remote
473 : * server. If the initial load fails, the callback will also be called.
474 : */
475 : virtual void setInitializedCb(std::function<void()> callback) PURE;
476 :
477 : /**
478 : * @return std::string last accepted version from fetch.
479 : */
480 : virtual const std::string versionInfo() const PURE;
481 : };
482 :
483 : using CdsApiPtr = std::unique_ptr<CdsApi>;
484 :
485 : /**
486 : * Factory for objects needed during cluster manager operation.
487 : */
488 : class ClusterManagerFactory {
489 : public:
490 317 : virtual ~ClusterManagerFactory() = default;
491 :
492 : /**
493 : * Allocate a cluster manager from configuration proto.
494 : */
495 : virtual ClusterManagerPtr
496 : clusterManagerFromProto(const envoy::config::bootstrap::v3::Bootstrap& bootstrap) PURE;
497 :
498 : /**
499 : * Allocate an HTTP connection pool for the host. Pools are separated by 'priority',
500 : * 'protocol', and 'options->hashKey()', if any.
501 : */
502 : virtual Http::ConnectionPool::InstancePtr
503 : allocateConnPool(Event::Dispatcher& dispatcher, HostConstSharedPtr host,
504 : ResourcePriority priority, std::vector<Http::Protocol>& protocol,
505 : const absl::optional<envoy::config::core::v3::AlternateProtocolsCacheOptions>&
506 : alternate_protocol_options,
507 : const Network::ConnectionSocket::OptionsSharedPtr& options,
508 : const Network::TransportSocketOptionsConstSharedPtr& transport_socket_options,
509 : TimeSource& time_source, ClusterConnectivityState& state,
510 : Http::PersistentQuicInfoPtr& quic_info) PURE;
511 :
512 : /**
513 : * Allocate a TCP connection pool for the host. Pools are separated by 'priority' and
514 : * 'options->hashKey()', if any.
515 : */
516 : virtual Tcp::ConnectionPool::InstancePtr
517 : allocateTcpConnPool(Event::Dispatcher& dispatcher, HostConstSharedPtr host,
518 : ResourcePriority priority,
519 : const Network::ConnectionSocket::OptionsSharedPtr& options,
520 : Network::TransportSocketOptionsConstSharedPtr transport_socket_options,
521 : ClusterConnectivityState& state,
522 : absl::optional<std::chrono::milliseconds> tcp_pool_idle_timeout) PURE;
523 :
524 : /**
525 : * Allocate a cluster from configuration proto.
526 : */
527 : virtual absl::StatusOr<std::pair<ClusterSharedPtr, ThreadAwareLoadBalancerPtr>>
528 : clusterFromProto(const envoy::config::cluster::v3::Cluster& cluster, ClusterManager& cm,
529 : Outlier::EventLoggerSharedPtr outlier_event_logger, bool added_via_api) PURE;
530 :
531 : /**
532 : * Create a CDS API provider from configuration proto.
533 : */
534 : virtual CdsApiPtr createCds(const envoy::config::core::v3::ConfigSource& cds_config,
535 : const xds::core::v3::ResourceLocator* cds_resources_locator,
536 : ClusterManager& cm) PURE;
537 :
538 : /**
539 : * Returns the secret manager.
540 : */
541 : virtual Secret::SecretManager& secretManager() PURE;
542 :
543 : /**
544 : * Returns the singleton manager.
545 : */
546 : virtual Singleton::Manager& singletonManager() PURE;
547 : };
548 :
549 : /**
550 : * Factory for creating ClusterInfo
551 : */
552 : class ClusterInfoFactory {
553 : public:
554 135 : virtual ~ClusterInfoFactory() = default;
555 :
556 : /**
557 : * Parameters for createClusterInfo().
558 : */
559 : struct CreateClusterInfoParams {
560 : Server::Configuration::ServerFactoryContext& server_context_;
561 : const envoy::config::cluster::v3::Cluster& cluster_;
562 : const envoy::config::core::v3::BindConfig& bind_config_;
563 : Stats::Store& stats_;
564 : Ssl::ContextManager& ssl_context_manager_;
565 : const bool added_via_api_;
566 : ThreadLocal::SlotAllocator& tls_;
567 : };
568 :
569 : /**
570 : * This method returns a Upstream::ClusterInfoConstSharedPtr given construction parameters.
571 : */
572 : virtual Upstream::ClusterInfoConstSharedPtr
573 : createClusterInfo(const CreateClusterInfoParams& params) PURE;
574 : };
575 :
576 : } // namespace Upstream
577 : } // namespace Envoy
|