Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Barrier"/> class.
        /// </summary>
        /// <param name="getGeodesics">A <see cref="FactoryFor{IGeodesics}"/> to get the correctly scoped geodesics for path offsetting.</param>
        /// <param name="serializer"><see cref="ISerializer"/> used for serialization.</param>
        /// <param name="getEventStore">A <see cref="FactoryFor{IEventStore}"/> to get the correctly scoped EventStore to persist incoming events to.</param>
        /// <param name="eventProcessingHub"><see cref="IScopedEventProcessingHub"/> for processing incoming events.</param>
        /// <param name="logger"><see cref="ILogger"/> for logging purposes.</param>
        /// <param name="executionContextManager"><see cref="IExecutionContextManager"/> to set the correct context for processing events.</param>
        /// <param name="tenants"><see cref="ITenants"/> all the tenants that we will process events for.</param>
        /// <param name="tenantOffsetRepository"><see cref="ITenantOffsetRepository"/> for working with the offsets per tenant.</param>
        /// <param name="application"><see cref="Application"/> running.</param>
        /// <param name="boundedContext"><see cref="BoundedContext"/> running.</param>
        public Barrier(
            FactoryFor <IGeodesics> getGeodesics,
            ISerializer serializer,
            FactoryFor <IEventStore> getEventStore,
            IScopedEventProcessingHub eventProcessingHub,
            ILogger logger,
            IExecutionContextManager executionContextManager,
            ITenants tenants,
            ITenantOffsetRepository tenantOffsetRepository,
            Application application,
            BoundedContext boundedContext)
        {
            _logger                  = logger;
            _getGeodesics            = getGeodesics;
            _serializer              = serializer;
            _getEventStore           = getEventStore;
            _eventProcessingHub      = eventProcessingHub;
            _executionContextManager = executionContextManager;
            _tenants                 = tenants;
            _tenantOffsetRepository  = tenantOffsetRepository;

            _key = new EventHorizonKey(application, boundedContext);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QuantumTunnelConnection"/> class.
        /// </summary>
        /// <param name="horizonKey">The key for the connection.</param>
        /// <param name="destinationKey">The key for the destination.</param>
        /// <param name="address">Url for the <see cref="IEventHorizon"/> we're connecting to.</param>
        /// <param name="events"><see cref="IEnumerable{Artifact}">Events</see> to connect for.</param>
        /// <param name="getGeodesics">A <see cref="FactoryFor{IGeodesics}"/> to provide the correctly scoped geodesics instance for path offsetting.</param>
        /// <param name="getEventStore">A factory to provide the correctly scoped <see cref="IEventStore"/> to persist incoming events to.</param>
        /// <param name="eventProcessingHub"><see cref="IScopedEventProcessingHub"/> for processing incoming events.</param>
        /// <param name="serializer"><see cref="ISerializer"/> to use for deserializing content of commits.</param>
        /// <param name="logger"><see cref="ILogger"/> for logging purposes.</param>
        /// <param name="executionContextManager"><see cref="IExecutionContextManager"/> so we can set the correct context for the processing of the Events.</param>
        /// <param name="tenants"><see cref="ITenants"/> the tenants that we need to be aware of from the other bounded contexts.</param>
        /// <param name="tenantOffsetRepository"><see creF="ITenantOffsetRepository"/> to use for tracking offsets per tenant.</param>
        public QuantumTunnelConnection(
            EventHorizonKey horizonKey,
            EventHorizonKey destinationKey,
            string address,
            IEnumerable <Dolittle.Artifacts.Artifact> events,
            FactoryFor <IGeodesics> getGeodesics,
            FactoryFor <IEventStore> getEventStore,
            IScopedEventProcessingHub eventProcessingHub,
            ISerializer serializer,
            ILogger logger,
            IExecutionContextManager executionContextManager,
            ITenants tenants,
            ITenantOffsetRepository tenantOffsetRepository)
        {
            _address                    = address;
            _events                     = events;
            _logger                     = logger;
            _horizonKey                 = horizonKey;
            _destinationKey             = destinationKey;
            _getGeodesics               = getGeodesics;
            _serializer                 = serializer;
            _getEventStore              = getEventStore;
            _eventProcessingHub         = eventProcessingHub;
            _channel                    = new Channel(_address, ChannelCredentials.Insecure);
            _client                     = new QuantumTunnelService.QuantumTunnelServiceClient(_channel);
            _runCancellationTokenSource = new CancellationTokenSource();
            _runCancellationToken       = _runCancellationTokenSource.Token;
            _executionContextManager    = executionContextManager;
            _processor                  = new ParticleStreamProcessor(getEventStore, getGeodesics, _destinationKey, eventProcessingHub, _executionContextManager, logger);
            _tenantOffsetRepository     = tenantOffsetRepository;
            _tenants                    = tenants;

            AppDomain.CurrentDomain.ProcessExit   += ProcessExit;
            AssemblyLoadContext.Default.Unloading += AssemblyLoadContextUnloading;
            Task.Run(() => Run(), _runCancellationToken);
            Console.CancelKeyPress += (s, e) => Close();
        }