forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lds_subscription.h
60 lines (50 loc) · 2.06 KB
/
lds_subscription.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
55
56
57
58
59
60
#pragma once
#include "envoy/api/v2/lds.pb.h"
#include "envoy/api/v2/listener/listener.pb.h"
#include "envoy/config/subscription.h"
#include "common/common/assert.h"
#include "common/common/logger.h"
#include "common/http/rest_api_fetcher.h"
#include "common/json/json_validator.h"
namespace Envoy {
namespace Server {
/**
* Subscription implementation that reads listener information from the v1 REST Listener Discovery
* Service.
*/
class LdsSubscription : public Http::RestApiFetcher,
public Config::Subscription<envoy::api::v2::Listener>,
Logger::Loggable<Logger::Id::upstream> {
public:
LdsSubscription(Config::SubscriptionStats stats,
const envoy::api::v2::core::ConfigSource& lds_config,
Upstream::ClusterManager& cm, Event::Dispatcher& dispatcher,
Runtime::RandomGenerator& random, const LocalInfo::LocalInfo& local_info);
private:
// Config::Subscription
void start(const std::vector<std::string>& resources,
Config::SubscriptionCallbacks<envoy::api::v2::Listener>& callbacks) override {
// LDS subscribes to all clusters.
ASSERT(resources.empty());
callbacks_ = &callbacks;
RestApiFetcher::initialize();
}
void updateResources(const std::vector<std::string>& resources) override {
// We should never hit this at runtime, since this legacy adapter is only used by CdsApiImpl
// that doesn't do dynamic modification of resources.
UNREFERENCED_PARAMETER(resources);
NOT_IMPLEMENTED;
}
const std::string versionInfo() const override { return version_info_; }
// Http::RestApiFetcher
void createRequest(Http::Message& request) override;
void parseResponse(const Http::Message& response) override;
void onFetchComplete() override;
void onFetchFailure(const EnvoyException* e) override;
std::string version_info_;
const LocalInfo::LocalInfo& local_info_;
Config::SubscriptionCallbacks<envoy::api::v2::Listener>* callbacks_ = nullptr;
Config::SubscriptionStats stats_;
};
} // namespace Server
} // namespace Envoy