예제 #1
0
        /// <summary>
        /// Extension method to add services into the <see cref="IServiceCollection"/>
        /// </summary>
        /// <param name="services"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static IServiceCollection AddKubernetesProbeListener(this IServiceCollection services, IConfiguration configuration)
        {
            IConfigurationSection configurationSection = configuration.GetSection(ProbePorts.SECTIONNAME);
            ProbePorts            settings             = configurationSection.Get <ProbePorts>();

            if (settings is null)
            {
                throw new KubernetesProbeListenerException($"Configuration section named {ProbePorts.SECTIONNAME} could not be serialized into type {typeof(PiConfiguration)}.  Please check the spelling of the configuration section name.");
            }
            services.AddSingleton(resolver => settings);
            services.AddSingleton <IKubernetesProbeListener, KubernetesProbeListenerService>();

            return(services);
        }
 public KubernetesProbeListenerService(ILogger <KubernetesProbeListenerService> logger, ProbePorts probePorts)
 {
     _logger     = logger;
     _probePorts = probePorts;
 }