/// <summary>
        /// Creates a <see cref="ISubscriptionGroup"/> for the given configuration.
        /// </summary>
        /// <param name="defaults">The default values to use while building each <see cref="SubscriptionGroup"/>.</param>
        /// <param name="subscriptionGroupSettings"></param>
        /// <returns>An <see cref="ISubscriptionGroup"/> to run.</returns>
        public ISubscriptionGroup Create(
            SubscriptionGroupSettingsBuilder defaults,
            IDictionary <string, SubscriptionGroupConfigBuilder> subscriptionGroupSettings)
        {
            ReceiveMiddleware receiveMiddleware = defaults.SqsMiddleware ?? _defaultSqsMiddleware;

            List <ISubscriptionGroup> groups = subscriptionGroupSettings
                                               .Values
                                               .Select(builder => Create(receiveMiddleware, builder.Build(defaults)))
                                               .ToList();

            return(new SubscriptionGroupCollection(
                       groups,
                       _loggerFactory.CreateLogger <SubscriptionGroupCollection>()));
        }
        /// <summary>
        /// Given a set of defaults and overrides from this builder, builds a concrete <see cref="SubscriptionGroupSettings"/>
        /// that can be passed to an <see cref="ISubscriptionGroupFactory"/> to build an <see cref="ISubscriptionGroup"/>.
        /// </summary>
        /// <param name="defaults">The default values to use if no override given.</param>
        /// <returns>A <see cref="SubscriptionGroupSettings"/>.</returns>
        public SubscriptionGroupSettings Build(SubscriptionGroupSettingsBuilder defaults)
        {
            if (defaults == null)
            {
                throw new InvalidOperationException("Defaults must be set before building settings.");
            }

            var settings = new SubscriptionGroupSettings(
                _groupName,
                _concurrencyLimit ?? defaults.ConcurrencyLimit,
                _bufferSize ?? defaults.BufferSize,
                _receiveBufferReadTimeout ?? defaults.ReceiveBufferReadTimeout,
                _recieveMessagesWaitTime ?? defaults.ReceiveMessagesWaitTime,
                _multiplexerCapacity ?? defaults.MultiplexerCapacity,
                _prefetch ?? defaults.Prefetch,
                _sqsQueues);

            settings.Validate();

            return(settings);
        }