1
#include "source/extensions/health_checkers/redis/config.h"
2

            
3
#include "envoy/config/core/v3/health_check.pb.h"
4
#include "envoy/extensions/filters/network/redis_proxy/v3/redis_proxy.pb.h"
5
#include "envoy/extensions/filters/network/redis_proxy/v3/redis_proxy.pb.validate.h"
6
#include "envoy/registry/registry.h"
7

            
8
#include "source/common/config/utility.h"
9
#include "source/extensions/health_checkers/redis/utility.h"
10

            
11
namespace Envoy {
12
namespace Extensions {
13
namespace HealthCheckers {
14
namespace RedisHealthChecker {
15

            
16
Upstream::HealthCheckerSharedPtr RedisHealthCheckerFactory::createCustomHealthChecker(
17
    const envoy::config::core::v3::HealthCheck& config,
18
5
    Server::Configuration::HealthCheckerFactoryContext& context) {
19

            
20
5
  auto redis_config = getRedisHealthCheckConfig(config, context.messageValidationVisitor());
21

            
22
5
  absl::optional<envoy::extensions::filters::network::redis_proxy::v3::AwsIam> aws_iam_config;
23
5
  if (redis_config.has_aws_iam()) {
24
1
    aws_iam_config = redis_config.aws_iam();
25
1
    aws_iam_authenticator_ =
26
1
        NetworkFilters::Common::Redis::AwsIamAuthenticator::AwsIamAuthenticatorFactory::
27
1
            initAwsIamAuthenticator(context.serverFactoryContext(), redis_config.aws_iam());
28
1
  }
29

            
30
5
  return std::make_shared<RedisHealthChecker>(
31
5
      context.cluster(), config,
32
5
      getRedisHealthCheckConfig(config, context.messageValidationVisitor()),
33
5
      context.mainThreadDispatcher(), context.runtime(), context.eventLogger(), context.api(),
34
5
      NetworkFilters::Common::Redis::Client::ClientFactoryImpl::instance_, aws_iam_config,
35
5
      aws_iam_authenticator_);
36
5
};
37

            
38
/**
39
 * Static registration for the redis custom health checker. @see RegisterFactory.
40
 */
41
REGISTER_FACTORY(RedisHealthCheckerFactory, Server::Configuration::CustomHealthCheckerFactory);
42

            
43
} // namespace RedisHealthChecker
44
} // namespace HealthCheckers
45
} // namespace Extensions
46
} // namespace Envoy