public FeatureSwitchByConfigMissingConfigStrategySilentOnTests()
        {
            _registry = new SubscriberRegistry();
            _registry.Register <MyCommand, MyFeatureSwitchedConfigHandler>();

            var container = new ServiceCollection();

            container.AddSingleton <MyFeatureSwitchedConfigHandler>();
            container.AddTransient <FeatureSwitchHandler <MyCommand> >();

            _provider       = container.BuildServiceProvider();
            _handlerFactory = new ServiceProviderHandlerFactory(_provider);


            _featureSwitchRegistry = new FakeConfigRegistry();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when no task queue support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="handlerFactory">The handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="featureSwitchRegistry">The feature switch config provider.</param>
 /// <param name="inboxConfiguration">Do we want to insert an inbox handler into pipelines without the attribute. Null (default = no), yes = how to configure</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactory handlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IPolicyRegistry <string> policyRegistry,
     IAmAFeatureSwitchRegistry featureSwitchRegistry = null,
     InboxConfiguration inboxConfiguration           = null
     )
 {
     _subscriberRegistry    = subscriberRegistry;
     _handlerFactory        = handlerFactory;
     _requestContextFactory = requestContextFactory;
     _policyRegistry        = policyRegistry;
     _featureSwitchRegistry = featureSwitchRegistry;
     _inboxConfiguration    = inboxConfiguration;
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when only task queue support is required
 /// </summary>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="asyncMessageStore">The message store supporting async/await.</param>
 /// <param name="asyncMessageProducer">The messaging gateway supporting async/await.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 /// <param name="featureSwitchRegistry">The feature switch config provider.</param>
 public CommandProcessor(
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStoreAsync <Message> asyncMessageStore,
     IAmAMessageProducerAsync asyncMessageProducer,
     int messageStoreTimeout = 300,
     IAmAFeatureSwitchRegistry featureSwitchRegistry = null)
 {
     _requestContextFactory = requestContextFactory;
     _policyRegistry        = policyRegistry;
     _messageStoreTimeout   = messageStoreTimeout;
     _mapperRegistry        = mapperRegistry;
     _asyncMessageStore     = asyncMessageStore;
     _asyncMessageProducer  = asyncMessageProducer;
     _featureSwitchRegistry = featureSwitchRegistry;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when only task queue support is required
 /// </summary>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 /// <param name="featureSwitchRegistry">The feature switch config provider.</param>
 public CommandProcessor(
     IAmARequestContextFactory requestContextFactory,
     IPolicyRegistry <string> policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStore <Message> messageStore,
     IAmAMessageProducer messageProducer,
     int messageStoreTimeout = 300,
     IAmAFeatureSwitchRegistry featureSwitchRegistry = null)
 {
     _requestContextFactory = requestContextFactory;
     _policyRegistry        = policyRegistry;
     _messageStoreTimeout   = messageStoreTimeout;
     _mapperRegistry        = mapperRegistry;
     _messageStore          = messageStore;
     _messageProducer       = messageProducer;
     _featureSwitchRegistry = featureSwitchRegistry;
 }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both task queue and command processor support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="asyncHandlerFactory">The async handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="asyncMessageStore">The message store supporting async/await.</param>
 /// <param name="asyncMessageProducer">The messaging gateway supporting async/await.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 /// <param name="featureSwitchRegistry">The feature switch config provider.</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactoryAsync asyncHandlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageStoreAsync <Message> asyncMessageStore,
     IAmAMessageProducerAsync asyncMessageProducer,
     int messageStoreTimeout = 300,
     IAmAFeatureSwitchRegistry featureSwitchRegistry = null)
     : this(subscriberRegistry, asyncHandlerFactory, requestContextFactory, policyRegistry, featureSwitchRegistry)
 {
     _mapperRegistry        = mapperRegistry;
     _asyncMessageStore     = asyncMessageStore;
     _asyncMessageProducer  = asyncMessageProducer;
     _messageStoreTimeout   = messageStoreTimeout;
     _featureSwitchRegistry = featureSwitchRegistry;
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both rpc and command processor support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="handlerFactory">The handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageStore">The message store.</param>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="responseChannelFactory">If we are expecting a response, then we need a channel to listen on</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 /// <param name="featureSwitchRegistry">The feature switch config provider.</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactory handlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IAmAPolicyRegistry policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageProducer messageProducer,
     int messageStoreTimeout = 300,
     IAmAFeatureSwitchRegistry featureSwitchRegistry = null,
     IAmAChannelFactory responseChannelFactory       = null)
     : this(subscriberRegistry, handlerFactory, requestContextFactory, policyRegistry)
 {
     _mapperRegistry         = mapperRegistry;
     _messageProducer        = messageProducer;
     _messageStoreTimeout    = messageStoreTimeout;
     _featureSwitchRegistry  = featureSwitchRegistry;
     _responseChannelFactory = responseChannelFactory;
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when only task queue support is required
 /// </summary>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="asyncOutbox">The outbox supporting async/await.</param>
 /// <param name="asyncMessageProducer">The messaging gateway supporting async/await.</param>
 /// <param name="outboxTimeout">How long should we wait to write to the outbox</param>
 /// <param name="featureSwitchRegistry">The feature switch config provider.</param>
 /// <param name="inboxConfiguration">Do we want to insert an inbox handler into pipelines without the attribute. Null (default = no), yes = how to configure</param>
 public CommandProcessor(
     IAmARequestContextFactory requestContextFactory,
     IPolicyRegistry <string> policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAnOutboxAsync <Message> asyncOutbox,
     IAmAMessageProducerAsync asyncMessageProducer,
     int outboxTimeout = 300,
     IAmAFeatureSwitchRegistry featureSwitchRegistry = null,
     InboxConfiguration inboxConfiguration           = null)
 {
     _requestContextFactory = requestContextFactory;
     _policyRegistry        = policyRegistry;
     _outboxTimeout         = outboxTimeout;
     _mapperRegistry        = mapperRegistry;
     _asyncOutbox           = asyncOutbox;
     _asyncMessageProducer  = asyncMessageProducer;
     _featureSwitchRegistry = featureSwitchRegistry;
     _inboxConfiguration    = inboxConfiguration;
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both rpc and command processor support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="handlerFactory">The handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="messageProducer">The messaging gateway.</param>
 /// <param name="responseChannelFactory">If we are expecting a response, then we need a channel to listen on</param>
 /// <param name="outboxTimeout">How long should we wait to write to the outbox</param>
 /// <param name="featureSwitchRegistry">The feature switch config provider.</param>
 /// <param name="inboxConfiguration">Do we want to insert an inbox handler into pipelines without the attribute. Null (default = no), yes = how to configure</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactory handlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IPolicyRegistry <string> policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAMessageProducer messageProducer,
     int outboxTimeout = 300,
     IAmAFeatureSwitchRegistry featureSwitchRegistry = null,
     IAmAChannelFactory responseChannelFactory       = null,
     InboxConfiguration inboxConfiguration           = null)
     : this(subscriberRegistry, handlerFactory, requestContextFactory, policyRegistry)
 {
     _mapperRegistry         = mapperRegistry;
     _messageProducer        = messageProducer;
     _outboxTimeout          = outboxTimeout;
     _featureSwitchRegistry  = featureSwitchRegistry;
     _responseChannelFactory = responseChannelFactory;
     _inboxConfiguration     = inboxConfiguration;
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
 /// Use this constructor when both task queue and command processor support is required
 /// </summary>
 /// <param name="subscriberRegistry">The subscriber registry.</param>
 /// <param name="asyncHandlerFactory">The async handler factory.</param>
 /// <param name="requestContextFactory">The request context factory.</param>
 /// <param name="policyRegistry">The policy registry.</param>
 /// <param name="mapperRegistry">The mapper registry.</param>
 /// <param name="asyncOutbox">The outbox supporting async/await.</param>
 /// <param name="asyncMessageProducer">The messaging gateway supporting async/await.</param>
 /// <param name="messageStoreTimeout">How long should we wait to write to the message store</param>
 /// <param name="featureSwitchRegistry">The feature switch config provider.</param>
 /// <param name="inboxConfiguration">Do we want to insert an inbox handler into pipelines without the attribute. Null (default = no), yes = how to configure</param>
 public CommandProcessor(
     IAmASubscriberRegistry subscriberRegistry,
     IAmAHandlerFactoryAsync asyncHandlerFactory,
     IAmARequestContextFactory requestContextFactory,
     IPolicyRegistry <string> policyRegistry,
     IAmAMessageMapperRegistry mapperRegistry,
     IAmAnOutboxAsync <Message> asyncOutbox,
     IAmAMessageProducerAsync asyncMessageProducer,
     int messageStoreTimeout = 300,
     IAmAFeatureSwitchRegistry featureSwitchRegistry = null,
     InboxConfiguration inboxConfiguration           = null)
     : this(subscriberRegistry, asyncHandlerFactory, requestContextFactory, policyRegistry, featureSwitchRegistry)
 {
     _mapperRegistry        = mapperRegistry;
     _asyncOutbox           = asyncOutbox;
     _asyncMessageProducer  = asyncMessageProducer;
     _messageStoreTimeout   = messageStoreTimeout;
     _featureSwitchRegistry = featureSwitchRegistry;
     _inboxConfiguration    = inboxConfiguration;
 }
Exemple #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandProcessor"/> class.
        /// Use this constructor when both external bus and command processor support is required
        /// </summary>
        /// <param name="subscriberRegistry">The subscriber registry.</param>
        /// <param name="handlerFactory">The handler factory.</param>
        /// <param name="requestContextFactory">The request context factory.</param>
        /// <param name="policyRegistry">The policy registry.</param>
        /// <param name="mapperRegistry">The mapper registry.</param>
        /// <param name="outBox">The outbox.</param>
        /// <param name="producerRegistry">The register of producers via whom we send messages over the external bus</param>
        /// <param name="outboxTimeout">How long should we wait to write to the outbox</param>
        /// <param name="featureSwitchRegistry">The feature switch config provider.</param>
        /// <param name="inboxConfiguration">Do we want to insert an inbox handler into pipelines without the attribute. Null (default = no), yes = how to configure</param>
        /// <param name="boxTransactionConnectionProvider">The Box Connection Provider to use when Depositing into the outbox.</param>
        public CommandProcessor(
            IAmASubscriberRegistry subscriberRegistry,
            IAmAHandlerFactory handlerFactory,
            IAmARequestContextFactory requestContextFactory,
            IPolicyRegistry <string> policyRegistry,
            IAmAMessageMapperRegistry mapperRegistry,
            IAmAnOutbox <Message> outBox,
            IAmAProducerRegistry producerRegistry,
            int outboxTimeout = 300,
            IAmAFeatureSwitchRegistry featureSwitchRegistry = null,
            InboxConfiguration inboxConfiguration           = null,
            IAmABoxTransactionConnectionProvider boxTransactionConnectionProvider = null)
            : this(subscriberRegistry, handlerFactory, requestContextFactory, policyRegistry, featureSwitchRegistry)
        {
            _mapperRegistry     = mapperRegistry;
            _inboxConfiguration = inboxConfiguration;
            _boxTransactionConnectionProvider = boxTransactionConnectionProvider;

            InitExtServiceBus(policyRegistry, outBox, outboxTimeout, producerRegistry);

            ConfigureCallbacks(producerRegistry);
        }
Exemple #11
0
 /// <summary>
 /// Supplies the specified feature switching configuration, so we can use feature switches on user-defined request handlers
 /// </summary>
 /// <param name="featureSwitchRegistry">The feature switch config provider</param>
 /// <returns>INeedARequestContext</returns>
 public INeedARequestContext ConfigureFeatureSwitches(IAmAFeatureSwitchRegistry featureSwitchRegistry)
 {
     _featureSwitchRegistry = featureSwitchRegistry;
     return(this);
 }
Exemple #12
0
 /// <summary>
 /// Supplies the specified feature switching configuration, so we can use feature switches on user-defined request handlers
 /// </summary>
 /// <param name="featureSwitchRegistry">The feature switch config provider</param>
 /// <returns>INeedPolicy</returns>
 public INeedAHandlers ConfigureFeatureSwitches(IAmAFeatureSwitchRegistry featureSwitchRegistry)
 {
     _featureSwitchRegistry = featureSwitchRegistry;
     return(this);
 }
Exemple #13
0
 /// <summary>
 /// Configure a Feature Switch registry to control handlers to be feature switched at runtime
 /// </summary>
 /// <param name="brighterBuilder">The Brighter builder to add this option to</param>
 /// <param name="featureSwitchRegistry">The registry for handler Feature Switches</param>
 /// <returns>The Brighter builder to allow chaining of requests</returns>
 public static IBrighterBuilder UseFeatureSwitches(this IBrighterBuilder brighterBuilder, IAmAFeatureSwitchRegistry featureSwitchRegistry)
 {
     brighterBuilder.Services.AddSingleton(featureSwitchRegistry);
     return(brighterBuilder);
 }