Coverage Report

Created: 2023-11-12 09:30

/proc/self/cwd/source/extensions/load_balancing_policies/ring_hash/config.cc
Line
Count
Source (jump to first uncovered line)
1
#include "source/extensions/load_balancing_policies/ring_hash/config.h"
2
3
#include "source/extensions/load_balancing_policies/ring_hash/ring_hash_lb.h"
4
5
namespace Envoy {
6
namespace Extensions {
7
namespace LoadBalancingPolices {
8
namespace RingHash {
9
10
Upstream::ThreadAwareLoadBalancerPtr
11
Factory::create(OptRef<const Upstream::LoadBalancerConfig> lb_config,
12
                const Upstream::ClusterInfo& cluster_info,
13
                const Upstream::PrioritySet& priority_set, Runtime::Loader& runtime,
14
0
                Random::RandomGenerator& random, TimeSource&) {
15
16
0
  auto active_or_legacy =
17
0
      Common::ActiveOrLegacy<Upstream::TypedRingHashLbConfig,
18
0
                             Upstream::LegacyRingHashLbConfig>::get(lb_config.ptr());
19
20
  // Assume legacy config.
21
0
  if (!active_or_legacy.hasActive()) {
22
0
    return std::make_unique<Upstream::RingHashLoadBalancer>(
23
0
        priority_set, cluster_info.lbStats(), cluster_info.statsScope(), runtime, random,
24
0
        !active_or_legacy.hasLegacy() ? cluster_info.lbRingHashConfig()
25
0
                                      : active_or_legacy.legacy()->lbConfig(),
26
0
        cluster_info.lbConfig());
27
0
  }
28
29
0
  return std::make_unique<Upstream::RingHashLoadBalancer>(
30
0
      priority_set, cluster_info.lbStats(), cluster_info.statsScope(), runtime, random,
31
0
      PROTOBUF_PERCENT_TO_ROUNDED_INTEGER_OR_DEFAULT(cluster_info.lbConfig(),
32
0
                                                     healthy_panic_threshold, 100, 50),
33
0
      active_or_legacy.active()->lb_config_);
34
0
}
35
36
/**
37
 * Static registration for the Factory. @see RegisterFactory.
38
 */
39
REGISTER_FACTORY(Factory, Upstream::TypedLoadBalancerFactory);
40
41
} // namespace RingHash
42
} // namespace LoadBalancingPolices
43
} // namespace Extensions
44
} // namespace Envoy