/// <inheritdoc />
        public IEnumerable <TenantOffset> Get(IEnumerable <TenantId> tenants, EventHorizonKey key)
        {
            var offsets = new List <TenantOffset>();

            Parallel.ForEach(tenants, (tenant) =>
            {
                _executionContextManager.CurrentFor(tenant);
                using (var geodesics = _getGeodesics())
                {
                    var offset = geodesics.GetOffset(key);
                    offsets.Add(new TenantOffset(tenant, offset));
                }
            });
            return(offsets);
        }
        /// <summary>
        /// Instantiates an instance of ParticleStreamConsumer
        /// </summary>

        /// <param name="getEventStore"><see cref="FactoryFor{IEventStore}" /> factory function that returns a correctly scoped <see cref="IEventStore" /></param>
        /// <param name="getGeodesics"><see cref="FactoryFor{IGeodesics}" /> factory function that returns a correctly scoped <see cref="IGeodesics" /></param>
        /// <param name="key">The <see cref="EventHorizonKey" /> to identify the Event Horizon</param>
        /// <param name="processingHub"><see cref="IScopedEventProcessingHub" /> for processing events from the <see cref="CommittedEventStream" /></param>
        /// <param name="executionContextManager"></param>
        /// <param name="logger"><see cref="ILogger" /> for logging</param>
        public ParticleStreamProcessor(
            FactoryFor <IEventStore> getEventStore,
            FactoryFor <IGeodesics> getGeodesics,
            EventHorizonKey key,
            IScopedEventProcessingHub processingHub,
            IExecutionContextManager executionContextManager,
            ILogger logger)
        {
            _getEventStore           = getEventStore;
            _getGeodesics            = getGeodesics;
            _processingHub           = processingHub;
            _eventHorizonKey         = key;
            _executionContextManager = executionContextManager;
            _logger = logger;
        }
 void SetOffset(EventHorizonKey key, CommitSequenceNumber commitSequenceNumber)
 {
     //the provider should accept the version and is responsible for transient errors and persisting it eventually
     try
     {
         using (var repository = _getGeodesics())
         {
             repository.SetOffset(_eventHorizonKey, commitSequenceNumber);
         }
     }
     catch (Exception ex)
     {
         _logger.Error($"Error setting offset for '{key}' : '{commitSequenceNumber}' - {ex.ToString()}");
     }
 }
Exemple #4
0
 /// <inheritdoc/>
 public void Penetrate(EventHorizonKey destinationKey, string url, IEnumerable <Artifact> events)
 {
     _logger.Information($"Penetrate barrier for quantum tunnel towards event horizon running at '{url}'");
     new QuantumTunnelConnection(
         _key,
         destinationKey,
         url,
         events,
         _getGeodesics,
         _getEventStore,
         _eventProcessingHub,
         _serializer,
         _logger,
         _executionContextManager,
         _tenants,
         _tenantOffsetRepository);
 }
Exemple #5
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);
        }