1
#pragma once
2

            
3
#include <memory>
4
#include <string>
5

            
6
#include "envoy/config/config_provider_manager.h"
7
#include "envoy/config/route/v3/route.pb.h"
8
#include "envoy/config/typed_config.h"
9
#include "envoy/event/dispatcher.h"
10
#include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.pb.h"
11
#include "envoy/init/manager.h"
12
#include "envoy/json/json_object.h"
13
#include "envoy/local_info/local_info.h"
14
#include "envoy/router/rds.h"
15
#include "envoy/runtime/runtime.h"
16
#include "envoy/server/filter_config.h"
17
#include "envoy/thread_local/thread_local.h"
18
#include "envoy/upstream/cluster_manager.h"
19

            
20
namespace Envoy {
21
namespace Router {
22

            
23
/**
24
 * The RouteConfigProviderManager exposes the ability to get a RouteConfigProvider. This interface
25
 * is exposed to the Server's FactoryContext in order to allow HttpConnectionManagers to get
26
 * RouteConfigProviders.
27
 */
28
class RouteConfigProviderManager {
29
public:
30
9801
  virtual ~RouteConfigProviderManager() = default;
31

            
32
  /**
33
   * Get a RouteConfigProviderPtr for a route from RDS. Ownership of the RouteConfigProvider is the
34
   * HttpConnectionManagers who calls this function. The RouteConfigProviderManager holds raw
35
   * pointers to the RouteConfigProviders. Clean up of the pointers happen from the destructor of
36
   * the RouteConfigProvider. This method creates a RouteConfigProvider which may share the
37
   * underlying RDS subscription with the same (route_config_name, cluster).
38
   * @param rds supplies the proto configuration of an RDS-configured RouteConfigProvider.
39
   * @param factory_context is the context to use for the route config provider.
40
   * @param stat_prefix supplies the stat_prefix to use for the provider stats.
41
   * @param init_manager the Init::Manager used to coordinate initialization of a the underlying RDS
42
   * subscription.
43
   */
44
  virtual RouteConfigProviderSharedPtr createRdsRouteConfigProvider(
45
      const envoy::extensions::filters::network::http_connection_manager::v3::Rds& rds,
46
      Server::Configuration::ServerFactoryContext& factory_context, const std::string& stat_prefix,
47
      Init::Manager& init_manager) PURE;
48

            
49
  /**
50
   * Get a RouteConfigSharedPtr for a statically defined route. Ownership is as described for
51
   * getRdsRouteConfigProvider above. This method always create a new RouteConfigProvider.
52
   * @param route_config supplies the RouteConfiguration for this route
53
   * @param factory_context is the context to use for the route config provider.
54
   * @param validator is the message validator for route config.
55
   */
56
  virtual RouteConfigProviderPtr
57
  createStaticRouteConfigProvider(const envoy::config::route::v3::RouteConfiguration& route_config,
58
                                  Server::Configuration::ServerFactoryContext& factory_context,
59
                                  ProtobufMessage::ValidationVisitor& validator) PURE;
60
};
61

            
62
using RouteConfigProviderManagerPtr = std::unique_ptr<RouteConfigProviderManager>;
63
using RouteConfigProviderManagerSharedPtr = std::shared_ptr<RouteConfigProviderManager>;
64

            
65
// This factory exists to avoid direct-linking the SRDS libraries into Envoy so
66
// they can be compiled or substituted out.
67
class SrdsFactory : public Envoy::Config::UntypedFactory {
68
public:
69
  // UntypedFactory
70
1007
  std::string category() const override { return "envoy.srds_factory"; }
71
  virtual std::unique_ptr<Envoy::Config::ConfigProviderManager>
72
  createScopedRoutesConfigProviderManager(
73
      Server::Configuration::ServerFactoryContext& factory_context,
74
      Router::RouteConfigProviderManager& route_config_provider_manager) PURE;
75
  // If enabled in the HttpConnectionManager config, returns a ConfigProvider for scoped routing
76
  // configuration.
77
  virtual Envoy::Config::ConfigProviderPtr createConfigProvider(
78
      const envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
79
          config,
80
      Server::Configuration::ServerFactoryContext& factory_context, Init::Manager& init_manager,
81
      const std::string& stat_prefix,
82
      Envoy::Config::ConfigProviderManager& scoped_routes_config_provider_manager) PURE;
83

            
84
  // If enabled in the HttpConnectionManager config, returns a ConfigProvider for scoped routing
85
  // configuration.
86
  virtual ScopeKeyBuilderPtr createScopeKeyBuilder(
87
      const envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
88
          config) PURE;
89
};
90

            
91
} // namespace Router
92
} // namespace Envoy