public async Task <bool> IsDuplicate(IPaymentsEvent earningEvent, CancellationToken cancellationToken)
        {
            logger.LogDebug($"Checking if earning event of type {earningEvent.GetType().Name} with guid: {earningEvent.EventId} has already been received.");
            var earningEventKey = new EarningEventKey(earningEvent);

            logger.LogDebug($"Earning event key: {earningEventKey.LogSafeKey}");
            if (await cache.Contains(earningEventKey.Key, cancellationToken).ConfigureAwait(false))
            {
                logger.LogWarning($"Key: {earningEventKey.LogSafeKey} found in the cache and is probably a duplicate.");
                return(true);
            }
            logger.LogDebug($"New earnings event. Event key: {earningEventKey.LogSafeKey}, event id: {earningEvent.EventId}");
            await cache.Add(earningEventKey.Key, earningEventKey, cancellationToken);

            logger.LogInfo($"Added new earnings event to cache. Key: {earningEventKey.LogSafeKey}");
            return(false);
        }
Пример #2
0
        public async Task <bool> IsDuplicate(ProcessLearnerCommand processLearnerCommand, CancellationToken cancellationToken)
        {
            logger.LogDebug($"Checking if command of type {processLearnerCommand.GetType().Name} with guid: {processLearnerCommand.CommandId} has already been received.");

            var learnerKey = new LearnerKey(processLearnerCommand);

            logger.LogDebug($"learner key: {learnerKey.LogSafeKey}");
            if (await cache.Contains(learnerKey.Key, cancellationToken).ConfigureAwait(false))
            {
                logger.LogWarning($"Key: {learnerKey.LogSafeKey} found in the cache and is probably a duplicate.");
                return(true);
            }
            logger.LogDebug($"New learner command. Command key: {learnerKey.LogSafeKey}, command id: {processLearnerCommand.CommandId}");
            await cache.Add(learnerKey.Key, learnerKey, cancellationToken);

            logger.LogInfo($"Added new earnings event to cache. Key: {learnerKey.LogSafeKey}");
            return(false);
        }