Exemplo n.º 1
0
        private void WaitForScheduler()
        {
            Scheduler.Done()
            .TimeoutAfter(Scenario.DefaultTimeout())
            .Wait();

            var configuration = Configuration.Current;

            var commandsInPipeline = configuration.Container.Resolve <CommandsInPipeline>();

            do
            {
                var pendingCommands = commandsInPipeline
                                      .Select(c => c.Result)
                                      .OfType <CommandScheduled>()
                                      .ToArray();

                if (pendingCommands.Any())
                {
                    var namesOfClocksWithPendingCommands = pendingCommands
                                                           .Select(s => s.Clock)
                                                           .OfType <Sql.CommandScheduler.Clock>()
                                                           .Select(c => c.Name)
                                                           .Distinct()
                                                           .ToArray();

                    if (namesOfClocksWithPendingCommands.Any())
                    {
                        var clockTrigger = configuration.SchedulerClockTrigger();

                        var appliedCommands = namesOfClocksWithPendingCommands
                                              .Select(clockName => clockTrigger.AdvanceClock(clockName,
                                                                                             Now(),
                                                                                             q => q.Take(1))
                                                      .TimeoutAfter(Scenario.DefaultTimeout())
                                                      .Result)
                                              .SelectMany(result => result.SuccessfulCommands
                                                          .Cast <ScheduledCommandResult>()
                                                          .Concat(result.FailedCommands))
                                              .ToArray();

                        if (!appliedCommands.Any())
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            } while (true);
        }
Exemplo n.º 2
0
        private void WaitForScheduler()
        {
            Scheduler.Done().Wait();

            if (schedulerClocks.Any())
            {
                var configuration = Configuration.Current;
                if (configuration.UsesSqlCommandScheduling())
                {
                    foreach (var clockName in schedulerClocks)
                    {
                        var sqlCommandScheduler = configuration.SqlCommandScheduler();
                        sqlCommandScheduler.AdvanceClock(clockName, Clock.Now()).Wait();
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void WaitForScheduler()
        {
            Scheduler.Done()
            .TimeoutAfter(TimeSpan.FromMinutes(1))
            .Wait();

            if (schedulerClocks.Any())
            {
                var configuration = Configuration.Current;
                if (configuration.IsUsingSqlCommandScheduling())
                {
                    foreach (var clockName in schedulerClocks)
                    {
                        var sqlCommandScheduler = configuration.SqlCommandScheduler();
                        sqlCommandScheduler
                        .AdvanceClock(clockName, Clock.Now())
                        .TimeoutAfter(TimeSpan.FromMinutes(1))
                        .Wait();
                    }
                }
            }
        }