Example #1
0
        /// <summary>
        /// Adds dispatcher and processor decorators that sends events to a <see cref="IBackgroundCommandEventRepository"/>.
        /// Do NOT forget to also register a <see cref="IBackgroundCommandEventRepository"/> service for this to work properly.
        /// </summary>
        /// <param name="builder">The <see cref="BackgroundBuilder"/>.</param>
        /// <returns>The configured <see cref="BackgroundBuilder"/>.</returns>
        public static BackgroundBuilder AddBackgroundCommandEventsRepositoryDecorators(this BackgroundBuilder builder)
        {
            if (builder is null)
            {
                throw new System.ArgumentNullException(nameof(builder));
            }

            builder.TryDecorateDispatcher <BackgroundCommandEventRepositoryDispatcherDecorator>();
            builder.TryDecorateProcessor <BackgroundCommandEventRepositoryProcessorDecorator>();
            return(builder);
        }
Example #2
0
        /// <summary>
        /// Adds Application Insights monitoring to background processing.
        /// </summary>
        /// <param name="builder">The <see cref="BackgroundBuilder"/>.</param>
        /// <param name="configureOptions">Configure the <see cref="TelemetryClientDecoratorOptions"/> if needed.</param>
        /// <returns>The configured <see cref="BackgroundBuilder"/>.</returns>
        public static BackgroundBuilder AddApplicationInsightsDecorators(
            this BackgroundBuilder builder,
            Action <TelemetryClientDecoratorOptions> configureOptions = null)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (configureOptions != null)
            {
                builder.Services.Configure(configureOptions);
            }

            builder.TryDecorateDispatcher <TelemetryClientDispatcherDecorator>();
            builder.TryDecorateProcessor <TelemetryClientProcessorDecorator>();
            return(builder);
        }