예제 #1
0
        private void RecreateBatchInserter()
        {
            // validate delay is valid
            TimeSpan delay = base.DatabaseOptions.CurrentValue.GroupConfigsBatchDelay;

            if (delay <= TimeSpan.Zero)
            {
                throw new ArgumentException("Batching delay must be greater than 0", nameof(base.DatabaseOptions.CurrentValue.GroupConfigsBatchDelay));
            }

            // flush existing inserter to not lose any changes
            if (_batchInserter != null)
            {
                _batchInserter.Flush();
            }
            _log?.LogDebug("Creating batch inserter for item type {ItemType} with delay of {Delay}", typeof(GroupConfig).Name, delay);
            _batchInserter = new MongoDelayedBatchInserter <uint, GroupConfig>(delay, _log);
            _batchInserter.UpdateCollection(_groupConfigsCollection);
        }