Exemplo n.º 1
0
        public PatLiteOptions Build()
        {
            EnsureTerminatingBehavioursAdded();

            var builder        = new MessagePipelineDependencyBuilder(_messagePipelineBehaviourTypes);
            var batchBuilder   = new BatchPipelineDependencyBuilder(_batchPipelineBehaviourTypes);
            var patliteOptions = new PatLiteOptions
            {
                SubscriberConfiguration          = _subscriberConfiguration,
                MessageProcessingPipelineBuilder = builder,
                BatchMessageProcessingBehaviourPipelineBuilder = batchBuilder,
                MessageDeserialiser   = _messageDeserialiser,
                CircuitBreakerOptions = _circuitBreakerOptions
            };

            return(patliteOptions);
        }
        /// <summary>
        /// <para>Registers dependencies required for PatLite, allowing customisaton through options</para>
        /// <para>NB: Recommend using parameterless AddPatLite() overload where default batch and message processing is desired</para>
        /// </summary>
        /// <param name="serviceCollection"></param>
        /// <param name="options">
        /// <para>Required SubscriberConfiguration</para>
        /// <para>Optional options.BatchMessageProcessingBehaviourPipelineBuilder override for custom batch pipelines, leave as null to build default pipeline</para>
        /// <para>Optional options.MessageProcessingPipelineBuilder override for custom message processing pipelines, leave as null to build default pipeline</para>
        /// </param>
        /// <returns></returns>
        public static IServiceCollection AddPatLite(this IServiceCollection serviceCollection, PatLiteOptions options)
        {
            options.AssemblyScanner?.RegisterHandlers(serviceCollection);

            return(serviceCollection
                   .AddSingleton(options.SubscriberConfiguration)
                   .RegisterPatLite(options.BatchMessageProcessingBehaviourPipelineBuilder,
                                    options.MessageProcessingPipelineBuilder,
                                    options.MessageDeserialiser,
                                    options.CircuitBreakerOptions));
        }