public ProcessKinesisEvents()

in functions/source/real-time-adherence/AspectKinesisLamda/ProcessKinesisEvents.cs [52:97]


        public ProcessKinesisEvents()
        {
            _dynamoDbTableName = Environment.GetEnvironmentVariable(DYNAMODB_TABLE_NAME_ENVIRONMENT_VARIABLE_LOOKUP);
            if (string.IsNullOrEmpty(_dynamoDbTableName))
            {
                throw new Exception($"Missing Lambda Variable {DYNAMODB_TABLE_NAME_ENVIRONMENT_VARIABLE_LOOKUP}");
            }
            _dynamoDbTableName = _dynamoDbTableName.Trim();
            AWSConfigsDynamoDB.Context.TypeMappings[typeof(ConnectKinesisEventRecord)] = new Amazon.Util.TypeMapping(typeof(ConnectKinesisEventRecord), _dynamoDbTableName);
            var aeConfig = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 };
            _aeDbContext = new DynamoDBContext(new AmazonDynamoDBClient(), aeConfig);
            _configTableName = Environment.GetEnvironmentVariable(CONFIG_TABLE_NAME_ENVIRONMENT_VARIABLE_LOOKUP);
            if (!string.IsNullOrEmpty(_configTableName))
            {
                _configTableName = _configTableName.Trim();
                AWSConfigsDynamoDB.Context.TypeMappings[typeof(ConfigRecord)] = new Amazon.Util.TypeMapping(typeof(ConfigRecord), _configTableName);
                var cfgConfig = new DynamoDBContextConfig { Conversion = DynamoDBEntryConversion.V2 };
                _cfgDbContext = new DynamoDBContext(new AmazonDynamoDBClient(), cfgConfig);
            }
            else
                _cfgDbContext = null;
            var level = Environment.GetEnvironmentVariable(AHG_FILTER_LEVEL_ENVIRONMENT_VARIABLE_LOOKUP);
            if (string.IsNullOrEmpty(level))
            {
                throw new Exception($"Missing Lambda Variable {AHG_FILTER_LEVEL_ENVIRONMENT_VARIABLE_LOOKUP}");
            }
            if (!int.TryParse(level, out _ahgFilterLevel) || _ahgFilterLevel < MIN_AHG_FILTER_LEVEL || _ahgFilterLevel > MAX_AHG_FILTER_LEVEL)
            {
                throw new Exception($"Invalid Lambda Variable {AHG_FILTER_LEVEL_ENVIRONMENT_VARIABLE_LOOKUP}: value must be an integer between {MIN_AHG_FILTER_LEVEL} and {MAX_AHG_FILTER_LEVEL}");
            }
            if (_ahgFilterLevel != AHG_FILTER_LEVEL_DISABLED)
            {
                var sep = Environment.GetEnvironmentVariable(AHG_FILTER_SEPARATOR_ENVIRONMENT_VARIABLE_LOOKUP);
                if (string.IsNullOrEmpty(sep))
                {
                    throw new Exception($"Missing Lambda Variable {AHG_FILTER_SEPARATOR_ENVIRONMENT_VARIABLE_LOOKUP}");
                }
                if (sep.Length != 1)
                {
                    throw new Exception($"Invalid Lambda Variable {AHG_FILTER_SEPARATOR_ENVIRONMENT_VARIABLE_LOOKUP}: value must be a single character");
                }
                _ahgFilterSeparator = sep[0];
                var values = Environment.GetEnvironmentVariable(AHG_FILTER_VALUES_ENVIRONMENT_VARIABLE_LOOKUP);
                _ahgFilterValues = new SortedSet<string>(values.Split(_ahgFilterSeparator), StringComparer.InvariantCultureIgnoreCase);
            }
        }