/// <summary>
        /// Store some KinesisTap conventional values to the parameter store.
        /// </summary>
        /// <param name="store">The <see cref="IParameterStore"/> instance.</param>
        /// <remarks>
        /// This is used to store conventional values to the parameter store when KT starts up.
        /// Any value set from the previous run of KT is overwritten.
        /// Doing this provides different KT classes (SessionManager, LogManager, PersistentConfigFileIdMap etc.) a unified way to resolve values,
        /// and allows easier testing as well.
        /// </remarks>
        public static void StoreConventionalValues(this IParameterStore store)
        {
            store.SetParameter(ConfigDirPathKey,
                               Path.Combine(Utility.GetKinesisTapConfigPath()));

            store.SetParameter(NLogConfigPathKey,
                               Path.Combine(Utility.GetNLogConfigDirectory(), NLogConfigFileName));
        }
Esempio n. 2
0
        /// <summary>
        /// Store some KinesisTap conventional values to the parameter store.
        /// </summary>
        /// <param name="store">The <see cref="IParameterStore"/> instance.</param>
        /// <remarks>
        /// This is used to store conventional values to the parameter store when KT starts up.
        /// Any value set from the previous run of KT is overwritten.
        /// Doing this provides different KT classes (SessionManager, LogManager, PersistentConfigFileIdMap etc.) a unified way to resolve values,
        /// and allows easier testing as well.
        /// </remarks>
        public static void StoreConventionalValues(this IParameterStore store)
        {
            store.SetParameter(NLogConfigPathKey,
                               Path.Combine(Utility.GetKinesisTapConfigPath(), "NLog.xml"));

            store.SetParameter(DefaultConfigurationPathKey,
                               Path.Combine(Utility.GetKinesisTapConfigPath(), DefaultConfigFileName));

            store.SetParameter(ExtraConfigurationDirectoryPathKey,
                               Utility.GetKinesisTapExtraConfigPath());

            store.SetParameter(BuildNumberKey,
                               ProgramInfo.GetBuildNumber().ToString());
        }
Esempio n. 3
0
        /// <inheritdoc/>
        public ValueTask <string> GetClientIdAsync(CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(_clientId))
            {
                _clientId = Guid.NewGuid().ToString();
                _parameterStore.SetParameter(ClientIdParameterName, _clientId);
            }

            return(ValueTask.FromResult(_clientId));
        }
        public SessionManagerTest(ITestOutputHelper output)
        {
            _testConfigDir      = Path.Combine(Path.GetTempPath(), "SessionManagerTest-" + Guid.NewGuid().ToString());
            _testMultiConfigDir = Path.Combine(_testConfigDir, "configs");

            // creating _testMultiConfigDir will create _testConfigDir also
            Directory.CreateDirectory(_testMultiConfigDir);

            File.Copy("NLog.xml", Path.Combine(_testConfigDir, "NLog.xml"));
            File.Copy("appsettings.json", Path.Combine(_testConfigDir, HostingUtility.DefaultConfigFileName));
            _parameterStore.SetParameter(HostingUtility.ConfigDirPathKey, _testConfigDir);
            _output = output;
            NLog.LogManager.LoadConfiguration("NLog.xml");
        }
        /// <inheritdoc/>
        /// <remarks>
        /// ID is retrieved from Cognito and saved to parameter store.
        /// </remarks>
        public async ValueTask <string> GetClientIdAsync(CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(_clientId))
            {
                var getIdResponse = await _cognitoIdentityClient.GetIdAsync(new GetIdRequest
                {
                    IdentityPoolId = IDENTITY_POOL_ID
                }, cancellationToken);

                _clientId = getIdResponse.IdentityId;
                _parameterStore.SetParameter(CLIENT_ID, _clientId);
            }

            return(_clientId);
        }
Esempio n. 6
0
        private void GenerateUniqueClientID()
        {
            //Generate a unique client id for the KinesisTap based on the system properties
            string uniqueClientID        = Utility.UniqueClientID;
            string currentUniqueClientID = _parameterStore.GetParameter(ConfigConstants.UNIQUE_CLIENT_ID);

            //Set Unique id here
            if (uniqueClientID != currentUniqueClientID)
            {
                _logger.LogInformation($"Unique Client ID of the system changed from '{currentUniqueClientID}' to '{uniqueClientID}' ");
                _parameterStore.SetParameter(ConfigConstants.UNIQUE_CLIENT_ID, uniqueClientID);
            }

            _logger.LogInformation($"Unique Client ID of the system is '{uniqueClientID}' ");
            _logger.LogInformation($"Unique System properties used to generate Unique Client ID is '{Utility.UniqueSystemProperties}' ");

            //Store the value in enviornment variable
            if (string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(ConfigConstants.UNIQUE_CLIENT_ID)))
            {
                Environment.SetEnvironmentVariable(ConfigConstants.UNIQUE_CLIENT_ID, uniqueClientID);
            }

            return;
        }