1
#include "source/extensions/load_balancing_policies/round_robin/config.h"
2

            
3
#include "envoy/extensions/load_balancing_policies/round_robin/v3/round_robin.pb.h"
4

            
5
namespace Envoy {
6
namespace Extensions {
7
namespace LoadBalancingPolicies {
8
namespace RoundRobin {
9

            
10
Upstream::LoadBalancerPtr RoundRobinCreator::operator()(
11
    Upstream::LoadBalancerParams params, OptRef<const Upstream::LoadBalancerConfig> lb_config,
12
    const Upstream::ClusterInfo& cluster_info, const Upstream::PrioritySet&,
13
22961
    Runtime::Loader& runtime, Random::RandomGenerator& random, TimeSource& time_source) {
14

            
15
22961
  const auto typed_lb_config =
16
22961
      dynamic_cast<const Upstream::TypedRoundRobinLbConfig*>(lb_config.ptr());
17
22961
  ASSERT(typed_lb_config != nullptr, "Invalid load balancer config");
18

            
19
22961
  return std::make_unique<Upstream::RoundRobinLoadBalancer>(
20
22961
      params.priority_set, params.local_priority_set, cluster_info.lbStats(), runtime, random,
21
22961
      PROTOBUF_PERCENT_TO_ROUNDED_INTEGER_OR_DEFAULT(cluster_info.lbConfig(),
22
22961
                                                     healthy_panic_threshold, 100, 50),
23
22961
      typed_lb_config->lb_config_, time_source);
24
22961
}
25

            
26
/**
27
 * Static registration for the Factory. @see RegisterFactory.
28
 */
29
REGISTER_FACTORY(Factory, Upstream::TypedLoadBalancerFactory);
30

            
31
} // namespace RoundRobin
32
} // namespace LoadBalancingPolicies
33
} // namespace Extensions
34
} // namespace Envoy