/// <summary>
        ///     Specifies the <see cref="BrokerConnectionOptions" />.
        /// </summary>
        /// <param name="brokerOptionsBuilder">
        ///     The <see cref="IBrokerOptionsBuilder" /> that references the <see cref="IServiceCollection" /> to
        ///     add the services to.
        /// </param>
        /// <param name="connectionOptions">
        ///     The <see cref="BrokerConnectionOptions" /> to apply.
        /// </param>
        /// <returns>
        ///     The <see cref="IBrokerOptionsBuilder" /> so that additional calls can be chained.
        /// </returns>
        public static IBrokerOptionsBuilder WithConnectionOptions(
            this IBrokerOptionsBuilder brokerOptionsBuilder,
            BrokerConnectionOptions connectionOptions)
        {
            Check.NotNull(brokerOptionsBuilder, nameof(brokerOptionsBuilder));

            brokerOptionsBuilder.SilverbackBuilder.Services.AddSingleton(connectionOptions);

            return(brokerOptionsBuilder);
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="BrokerConnectorService" /> class.
 /// </summary>
 /// <param name="serviceScopeFactory">
 ///     The <see cref="IServiceScopeFactory" />.
 /// </param>
 /// <param name="applicationLifetime">
 ///     The <see cref="IApplicationLifetime" />.
 /// </param>
 /// <param name="brokersCollection">
 ///     The <see cref="IBrokerCollection" />.
 /// </param>
 /// <param name="connectionOptions">
 ///     The <see cref="BrokerConnectionOptions" />.
 /// </param>
 /// <param name="logger">
 ///     The <see cref="ISilverbackLogger" />.
 /// </param>
 public BrokerConnectorService(
     IServiceScopeFactory serviceScopeFactory,
     IHostApplicationLifetime applicationLifetime,
     IBrokerCollection brokersCollection,
     BrokerConnectionOptions connectionOptions,
     ISilverbackLogger <BrokerConnectorService> logger)
 {
     _serviceScopeFactory = Check.NotNull(serviceScopeFactory, nameof(serviceScopeFactory));
     _applicationLifetime = Check.NotNull(applicationLifetime, nameof(applicationLifetime));
     _brokerCollection    = Check.NotNull(brokersCollection, nameof(brokersCollection));
     _connectionOptions   = Check.NotNull(connectionOptions, nameof(connectionOptions));
     _logger = Check.NotNull(logger, nameof(logger));
 }