private async Task SendElectionMessage() { await _orderEventRepository.DeclareElection(); await _orderEventRepository.CastVote(OrderEventProcessor.ProcessorId); OrderEventProcessor.State = new LeaderSelection(OrderEventProcessor); }
private async Task ProcessEvent() { Console.WriteLine("Follower->ProcessEvent"); var eventId = await _orderEventOutboxRepository.GetOrderEvent(OrderEventProcessor.ProcessorId); if (this.SchedulerStatus != "Election") { await Task.Run(() => { Console.WriteLine($"processing events {eventId}"); _orderEventOutboxRepository.MarkOrderEventPublished(eventId); }); } else { var candidates = await _orderEventRepository.GetActiveCandidates(); var random = new Random(candidates.Count); var candidate = candidates[random.Next()]; await _orderEventRepository.CastVote(candidate); } }