forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lds_api.h
54 lines (43 loc) · 1.71 KB
/
lds_api.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#pragma once
#include <functional>
#include "envoy/api/v2/lds.pb.h"
#include "envoy/config/subscription.h"
#include "envoy/init/init.h"
#include "envoy/server/listener_manager.h"
#include "envoy/stats/scope.h"
#include "common/common/logger.h"
namespace Envoy {
namespace Server {
/**
* LDS API implementation that fetches via Subscription.
*/
class LdsApiImpl : public LdsApi,
public Init::Target,
Config::SubscriptionCallbacks<envoy::api::v2::Listener>,
Logger::Loggable<Logger::Id::upstream> {
public:
LdsApiImpl(const envoy::api::v2::core::ConfigSource& lds_config, Upstream::ClusterManager& cm,
Event::Dispatcher& dispatcher, Runtime::RandomGenerator& random,
Init::Manager& init_manager, const LocalInfo::LocalInfo& local_info,
Stats::Scope& scope, ListenerManager& lm);
// Server::LdsApi
std::string versionInfo() const override { return version_info_; }
// Init::Target
void initialize(std::function<void()> callback) override;
// Config::SubscriptionCallbacks
void onConfigUpdate(const ResourceVector& resources, const std::string& version_info) override;
void onConfigUpdateFailed(const EnvoyException* e) override;
std::string resourceName(const ProtobufWkt::Any& resource) override {
return MessageUtil::anyConvert<envoy::api::v2::Listener>(resource).name();
}
private:
void runInitializeCallbackIfAny();
std::unique_ptr<Config::Subscription<envoy::api::v2::Listener>> subscription_;
std::string version_info_;
ListenerManager& listener_manager_;
Stats::ScopePtr scope_;
Upstream::ClusterManager& cm_;
std::function<void()> initialize_callback_;
};
} // namespace Server
} // namespace Envoy