Пример #1
0
 public static IServiceCollection OverrideTopicClientFactory(
     this IServiceCollection services,
     ITopicClientFactory instance)
 {
     services.Replace(new ServiceDescriptor(typeof(ITopicClientFactory), instance));
     return(services);
 }
Пример #2
0
        public EventPublisher(ITopicClientFactory topicClientFactory, IEventPublisherConfiguration configuration)
        {
            ValidateConstructorInputs(topicClientFactory, configuration);

            this.topicClientFactory = topicClientFactory;
            this.configuration      = configuration;
            topicClients            = new Dictionary <string, ITopicClient>();
        }
 public EventBus(
     AzureServiceBusPublisherConfiguration azureServiceBusPublisherConfiguration,
     ITopicClientFactory topicClientFactory,
     IMessageFactory messageFactory)
 {
     _azureServiceBusPublisherConfiguration = azureServiceBusPublisherConfiguration;
     _topicClientFactory = topicClientFactory;
     _messageFactory     = messageFactory;
 }
Пример #4
0
 public void Setup()
 {
     this.appSettings = new AppSettings();
     this.topicClient = A.Fake <ITopicClient>();
     this.appSettings.ServiceBusConfig.ConnectionString = "ConnectionString";
     this.message            = new Message(Array.Empty <byte>());
     this.topicClientFactory = A.Fake <ITopicClientFactory>();
     A.CallTo(() => this.topicClientFactory.Create(this.appSettings.ServiceBusConfig.ConnectionString)).Returns(this.topicClient);
     this.serviceBus = new ServiceBusSupport(this.topicClientFactory, this.appSettings);
     A.CallTo(() => this.topicClient.SendAsync(this.message)).Returns(Task.CompletedTask);
 }
Пример #5
0
 public AzureTopicEventSender(
     ILogger <AzureTopicEventSender> logger,
     IOptions <AzureTopicEventSenderOptions> config,
     IEventsSerializationService eventsSerializationService,
     ITopicClientFactory topicClientFactory
     )
 {
     _logger = logger;
     _eventsSerializationService = eventsSerializationService;
     _topicClient = topicClientFactory.GetNew(config.Value.SendConnectionString);
 }
Пример #6
0
        private static void ValidateConstructorInputs(
            ITopicClientFactory topicClientFactory,
            IEventPublisherConfiguration configuration)
        {
            topicClientFactory.GuardArgumentIsNotNull(nameof(topicClientFactory));

            configuration.GuardArgumentIsNotNull(nameof(configuration));
            configuration.ServiceBusConnectionString.GuardArgumentIsNotNullOrEmpty(
                $"{nameof(configuration)}.{nameof(configuration.ServiceBusConnectionString)}");
            configuration.Publishers.GuardArgumentIsNotNullOrEmpty(
                $"{nameof(configuration)}.{nameof(configuration.Publishers)}");
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InstanceFactory"/> class.
 /// </summary>
 /// <param name="ioManager">The value of <see cref="ioManager"/>.</param>
 /// <param name="databaseContextFactory">The value of <see cref="databaseContextFactory"/>.</param>
 /// <param name="assemblyInformationProvider">The value of <see cref="assemblyInformationProvider"/>.</param>
 /// <param name="loggerFactory">The value of <see cref="loggerFactory"/>.</param>
 /// <param name="topicClientFactory">The value of <see cref="topicClientFactory"/>.</param>
 /// <param name="cryptographySuite">The value of <see cref="cryptographySuite"/>.</param>
 /// <param name="synchronousIOManager">The value of <see cref="synchronousIOManager"/>.</param>
 /// <param name="symlinkFactory">The value of <see cref="symlinkFactory"/>.</param>
 /// <param name="byondInstaller">The value of <see cref="byondInstaller"/>.</param>
 /// <param name="chatFactory">The value of <see cref="chatFactory"/>.</param>
 /// <param name="processExecutor">The value of <see cref="processExecutor"/>.</param>
 /// <param name="postWriteHandler">The value of <see cref="postWriteHandler"/>.</param>
 /// <param name="watchdogFactory">The value of <see cref="watchdogFactory"/>.</param>
 /// <param name="jobManager">The value of <see cref="jobManager"/>.</param>
 /// <param name="networkPromptReaper">The value of <see cref="networkPromptReaper"/>.</param>
 /// <param name="platformIdentifier">The value of <see cref="platformIdentifier"/>.</param>
 /// <param name="repositoryFactory">The value of <see cref="repositoryFactory"/>.</param>
 /// <param name="repositoryCommands">The value of <see cref="repositoryCommands"/>.</param>
 /// <param name="serverPortProvider">The value of <see cref="serverPortProvider"/>.</param>
 /// <param name="fileTransferService">The value of <see cref="fileTransferService"/>.</param>
 /// <param name="gitRemoteFeaturesFactory">The value of <see cref="gitRemoteFeaturesFactory"/>.</param>
 /// <param name="remoteDeploymentManagerFactory">The value of <see cref="remoteDeploymentManagerFactory"/>.</param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/>.</param>
 public InstanceFactory(
     IIOManager ioManager,
     IDatabaseContextFactory databaseContextFactory,
     IAssemblyInformationProvider assemblyInformationProvider,
     ILoggerFactory loggerFactory,
     ITopicClientFactory topicClientFactory,
     ICryptographySuite cryptographySuite,
     ISynchronousIOManager synchronousIOManager,
     ISymlinkFactory symlinkFactory,
     IByondInstaller byondInstaller,
     IChatManagerFactory chatFactory,
     IProcessExecutor processExecutor,
     IPostWriteHandler postWriteHandler,
     IWatchdogFactory watchdogFactory,
     IJobManager jobManager,
     INetworkPromptReaper networkPromptReaper,
     IPlatformIdentifier platformIdentifier,
     ILibGit2RepositoryFactory repositoryFactory,
     ILibGit2Commands repositoryCommands,
     IServerPortProvider serverPortProvider,
     IFileTransferTicketProvider fileTransferService,
     IGitRemoteFeaturesFactory gitRemoteFeaturesFactory,
     IRemoteDeploymentManagerFactory remoteDeploymentManagerFactory,
     IOptions <GeneralConfiguration> generalConfigurationOptions)
 {
     this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
     this.databaseContextFactory      = databaseContextFactory ?? throw new ArgumentNullException(nameof(databaseContextFactory));
     this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider));
     this.loggerFactory                  = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
     this.topicClientFactory             = topicClientFactory ?? throw new ArgumentNullException(nameof(topicClientFactory));
     this.cryptographySuite              = cryptographySuite ?? throw new ArgumentNullException(nameof(cryptographySuite));
     this.synchronousIOManager           = synchronousIOManager ?? throw new ArgumentNullException(nameof(synchronousIOManager));
     this.symlinkFactory                 = symlinkFactory ?? throw new ArgumentNullException(nameof(symlinkFactory));
     this.byondInstaller                 = byondInstaller ?? throw new ArgumentNullException(nameof(byondInstaller));
     this.chatFactory                    = chatFactory ?? throw new ArgumentNullException(nameof(chatFactory));
     this.processExecutor                = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor));
     this.postWriteHandler               = postWriteHandler ?? throw new ArgumentNullException(nameof(postWriteHandler));
     this.watchdogFactory                = watchdogFactory ?? throw new ArgumentNullException(nameof(watchdogFactory));
     this.jobManager                     = jobManager ?? throw new ArgumentNullException(nameof(jobManager));
     this.networkPromptReaper            = networkPromptReaper ?? throw new ArgumentNullException(nameof(networkPromptReaper));
     this.platformIdentifier             = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier));
     this.repositoryFactory              = repositoryFactory ?? throw new ArgumentNullException(nameof(repositoryFactory));
     this.repositoryCommands             = repositoryCommands ?? throw new ArgumentNullException(nameof(repositoryCommands));
     this.serverPortProvider             = serverPortProvider ?? throw new ArgumentNullException(nameof(serverPortProvider));
     this.fileTransferService            = fileTransferService ?? throw new ArgumentNullException(nameof(fileTransferService));
     this.gitRemoteFeaturesFactory       = gitRemoteFeaturesFactory ?? throw new ArgumentNullException(nameof(gitRemoteFeaturesFactory));
     this.remoteDeploymentManagerFactory = remoteDeploymentManagerFactory ?? throw new ArgumentNullException(nameof(remoteDeploymentManagerFactory));
     generalConfiguration                = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
 }
Пример #8
0
        public EventProducer(ITopicClientFactory topicFactory, string topicBaseName, IEventSerializer eventSerializer, ILogger <EventProducer <TA, TKey> > logger)
        {
            if (topicFactory == null)
            {
                throw new ArgumentNullException(nameof(topicFactory));
            }
            if (string.IsNullOrWhiteSpace(topicBaseName))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(topicBaseName));
            }

            _logger          = logger;
            _eventSerializer = eventSerializer;
            var aggregateType = typeof(TA);

            this.TopicName = $"{topicBaseName}-{aggregateType.Name}";
            _topicClient   = topicFactory.Build(this.TopicName);
        }
Пример #9
0
        public void TestInitialize()
        {
            fixture            = new Fixture().Customize(new AutoNSubstituteCustomization());
            configuration      = fixture.Freeze <IEventPublisherConfiguration>();
            topicClientFactory = fixture.Freeze <ITopicClientFactory>();

            var publisherInfos =
                new List <PublisherInfo>
            {
                new PublisherInfo(typeof(FakeEvent1), TopicName1, RetryPolicyBase.DefaultRetry),
                new PublisherInfo(typeof(FakeEvent2), TopicName2, RetryPolicyBase.DefaultRetry)
            };

            configuration.Publishers.Returns(publisherInfos);
            configuration.ServiceBusConnectionString.Returns(fixture.Create <string>());

            sut = fixture.Create <EventPublisher>();
        }
        public DefaultTopicMessageSender(ILogger <DefaultTopicMessageSender> logger,
                                         ITopicClientFactory topicClientFactory,
                                         IMessageFactory messageFactory)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (topicClientFactory == null)
            {
                throw new ArgumentNullException(nameof(topicClientFactory));
            }
            if (messageFactory == null)
            {
                throw new ArgumentNullException(nameof(messageFactory));
            }

            _logger             = logger;
            _topicClientFactory = topicClientFactory;
            _messageFactory     = messageFactory;
        }
 public ServiceBusSupport(ITopicClientFactory topicClientFactory, AppSettings appSettings)
 {
     this.topicClientFactory = topicClientFactory;
     this.appSettings        = appSettings;
 }
 public MessageDispatcher(ITopicClientFactory topicClientFactory)
 {
     _topicClientFactory = topicClientFactory;
 }
Пример #13
0
 public LegacyTopicMessagePublisher(ITopicClientFactory topicClientFactory, ILogger <LegacyTopicMessagePublisher> logger, string connectionString)
 {
     _topicClientFactory = topicClientFactory;
     _logger             = logger;
     _connectionString   = connectionString;
 }