Exemplo n.º 1
0
 public ContainersMonitoringService Create(string name, ContainersGroupConfiguration configuration)
 {
     return(servicesCache.GetOrAdd(name, (x) =>
     {
         logger.LogInformation(LogEventId.MONITORING_SERVICE_FACTORY_CREATED, "Creating containers monitoring service for group {GroupName}", name);
         return new ContainersMonitoringService(CreateLogger(name), name, configuration, dockerClientFactory, globalCancellation, commandsExecutorFactory, eventsBus);
     }));
 }
Exemplo n.º 2
0
        protected Dictionary <string, IDictionary <string, bool> > ComposeFilter(ContainersGroupConfiguration configuration)
        {
            var output = new Dictionary <string, IDictionary <string, bool> >();

            var namesFilter = new Dictionary <string, bool>();

            foreach (var name in configuration.Containers)
            {
                namesFilter.Add(name, true);
            }

            output.Add("name", namesFilter);
            logger.LogInformation(LogEventId.MONITORING_SERVICE_FILTER_CREATED, "Created filter for group {Group}: {Filter}", groupName, output);

            return(output);
        }
Exemplo n.º 3
0
        public ContainersMonitoringService(ILogger logger,
                                           string groupName,
                                           ContainersGroupConfiguration configuration,
                                           DockerClientFactory dockerClientFactory,
                                           GlobalCancellationToken globalCancellation,
                                           CommandsExecutorFactory commandsExecutorFactory,
                                           EventsBus eventsBus)
        {
            this.logger                  = logger;
            this.groupName               = groupName;
            this.configuration           = configuration;
            this.dockerClientFactory     = dockerClientFactory;
            this.globalCancellation      = globalCancellation;
            this.commandsExecutorFactory = commandsExecutorFactory;
            this.eventsBus               = eventsBus;

            this.listParameters = new ContainersListParameters()
            {
                All     = true,
                Filters = ComposeFilter(configuration)
            };
        }