Example #1
0
        private async Task <MessageProcessResponse> onSettingsProcessAsync(InstanceSettingsMessage arg, CancellationToken stoppingToken)
        {
            if (stoppingToken.IsCancellationRequested)
            {
                return(MessageProcessResponse.Abandon);
            }

            InstanceSettingsDto dto = new InstanceSettingsDto()
            {
                ClientId = arg.InstanceId,
                IsActive = arg.IsActive,

                AggregationForHour  = arg.AggregationForHour,
                AggregationForDay   = arg.AggregationForDay,
                AggregationForWeek  = arg.AggregationForWeek,
                AggregationForMonth = arg.AggregationForMonth,

                CpuUsagePercentageMax       = arg.CpuMaxPercent,
                RamUsagePercentageMax       = arg.RamMaxPercent,
                LocalDiskUsagePercentageMax = arg.DiskMaxPercent,

                //validators are enabled by default
                //maybe in future we may add ability to change it
                CpuValidator        = true,
                RamValidator        = true,
                LocalDiskVallidator = true,
            };

            var x = await _instanceSettingsService.AddEntityAsync(dto);

            if (x == null)
            {
                return(MessageProcessResponse.Abandon);
            }
            return(MessageProcessResponse.Complete);
        }