Esempio n. 1
0
 /// <summary>
 /// Starts the event horizon.
 /// </summary>
 /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
 public async Task Start()
 {
     try
     {
         var tasks = new TaskGroup(
             _dispatcher.Accept(new SubscriptionResponse {
             ConsentId = Consent.ToProtobuf()
         }, _cancellationTokenSource.Token),
             ProcessEventsThroughEventHorizon());
         tasks.OnFirstTaskFailure += (_, ex) => Log.ErrorOccurredInEventHorizon(
             _logger,
             ex,
             Id.ConsumerMicroservice,
             Id.ConsumerTenant,
             Id.ProducerTenant,
             Id.Partition,
             Id.PublicStream);;
         tasks.OnAllTasksCompleted += () => Log.EventHorizonStopped(
             _logger,
             Id.ConsumerMicroservice,
             Id.ConsumerTenant,
             Id.ProducerTenant,
             Id.Partition,
             Id.PublicStream);
         await tasks.WaitForAllCancellingOnFirst(_cancellationTokenSource).ConfigureAwait(false);
     }
     finally
     {
         Log.EventHorizonDisconnecting(
             _logger,
             Id.ConsumerMicroservice,
             Id.ConsumerTenant,
             Id.ProducerTenant,
             Id.Partition,
             Id.PublicStream);
     }
 }