forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lds_api.h
50 lines (39 loc) · 1.55 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
#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 "common/common/logger.h"
namespace Envoy {
namespace Server {
/**
* LDS API implementation that fetches via Subscription.
*/
class LdsApi : public Init::Target,
Config::SubscriptionCallbacks<envoy::api::v2::Listener>,
Logger::Loggable<Logger::Id::upstream> {
public:
LdsApi(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);
const std::string versionInfo() const { return subscription_->versionInfo(); }
// Init::Target
void initialize(std::function<void()> callback) override;
// Config::SubscriptionCallbacks
void onConfigUpdate(const ResourceVector& resources) 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_;
ListenerManager& listener_manager_;
Stats::ScopePtr scope_;
Upstream::ClusterManager& cm_;
std::function<void()> initialize_callback_;
};
} // namespace Server
} // namespace Envoy