1
#pragma once
2

            
3
#include "envoy/config/cluster/v3/cluster.pb.h"
4

            
5
#include "source/common/upstream/cluster_factory_impl.h"
6
#include "source/common/upstream/upstream_impl.h"
7

            
8
namespace Envoy {
9
namespace Upstream {
10

            
11
class StaticClusterFactory;
12
class UpstreamImplTestBase;
13
/**
14
 * Implementation of Upstream::Cluster for static clusters (clusters that have a fixed number of
15
 * hosts with resolved IP addresses).
16
 */
17
class StaticClusterImpl : public ClusterImplBase {
18
public:
19
  // Upstream::Cluster
20
31716
  InitializePhase initializePhase() const override { return InitializePhase::Primary; }
21

            
22
protected:
23
  StaticClusterImpl(const envoy::config::cluster::v3::Cluster& cluster,
24
                    ClusterFactoryContext& context, absl::Status& creation_status);
25

            
26
private:
27
  friend class StaticClusterFactory;
28
  friend class UpstreamImplTestBase;
29

            
30
  // ClusterImplBase
31
  void startPreInit() override;
32

            
33
  PriorityStateManagerPtr priority_state_manager_;
34
  uint32_t overprovisioning_factor_;
35
  bool weighted_priority_health_;
36
};
37

            
38
/**
39
 * Factory for StaticClusterImpl cluster.
40
 */
41
class StaticClusterFactory : public ClusterFactoryImplBase {
42
public:
43
543
  StaticClusterFactory() : ClusterFactoryImplBase("envoy.cluster.static") {}
44

            
45
  absl::StatusOr<std::pair<ClusterImplBaseSharedPtr, ThreadAwareLoadBalancerPtr>>
46
  createClusterImpl(const envoy::config::cluster::v3::Cluster& cluster,
47
                    ClusterFactoryContext& context) override;
48
};
49

            
50
DECLARE_FACTORY(StaticClusterFactory);
51

            
52
} // namespace Upstream
53
} // namespace Envoy