1
#include "source/extensions/matching/input_matchers/runtime_fraction/config.h"
2

            
3
#include "envoy/extensions/matching/input_matchers/runtime_fraction/v3/runtime_fraction.pb.h"
4

            
5
namespace Envoy {
6
namespace Extensions {
7
namespace Matching {
8
namespace InputMatchers {
9
namespace RuntimeFraction {
10

            
11
Envoy::Matcher::InputMatcherFactoryCb
12
Config::createInputMatcherFactoryCb(const Protobuf::Message& config,
13
2
                                    Server::Configuration::ServerFactoryContext& factory_context) {
14
2
  const auto& runtime_fraction_config = MessageUtil::downcastAndValidate<
15
2
      const envoy::extensions::matching::input_matchers::runtime_fraction::v3::RuntimeFraction&>(
16
2
      config, factory_context.messageValidationVisitor());
17

            
18
2
  auto& runtime = factory_context.runtime();
19
2
  return [runtime_fraction_config, &runtime]() {
20
1
    return std::make_unique<Matcher>(runtime, runtime_fraction_config.runtime_fraction(),
21
1
                                     runtime_fraction_config.seed());
22
1
  };
23
2
}
24
/**
25
 * Static registration for the runtime fraction matcher. @see RegisterFactory.
26
 */
27
REGISTER_FACTORY(Config, Envoy::Matcher::InputMatcherFactory);
28

            
29
} // namespace RuntimeFraction
30
} // namespace InputMatchers
31
} // namespace Matching
32
} // namespace Extensions
33
} // namespace Envoy