public static ITaskSeriesTimer CreateTimer(IRecurrentCommand command, TimeSpan normalInterval,
                                               TimeSpan minimumInterval)
    {
        IDelayStrategy     delayStrategy = new LinearSpeedupStrategy(normalInterval, minimumInterval);
        ITaskSeriesCommand timerCommand  = new RecurrentTaskSeriesCommand(command, delayStrategy);

        return(new TaskSeriesTimer(timerCommand, Task.Delay(normalInterval)));
    }
Ejemplo n.º 2
0
        private ITaskSeriesTimer CreateLeaseRenewalTimer(TimeSpan leasePeriod, IDistributedLock lockHandle)
        {
            // renew the lease when it is halfway to expiring
            TimeSpan normalUpdateInterval = new TimeSpan(leasePeriod.Ticks / 2);

            IDelayStrategy     speedupStrategy = new LinearSpeedupStrategy(normalUpdateInterval, MinimumLeaseRenewalInterval);
            ITaskSeriesCommand command         = new RenewLeaseCommand(this._lockManager, lockHandle, speedupStrategy);

            return(new TaskSeriesTimer(command, this._exceptionHandler, Task.Delay(normalUpdateInterval)));
        }
Ejemplo n.º 3
0
        private ITaskSeriesTimer CreateLeaseRenewalTimer(IStorageBlockBlob leaseBlob, string leaseId, string lockId, TimeSpan leasePeriod,
                                                         IWebJobsExceptionHandler exceptionHandler)
        {
            // renew the lease when it is halfway to expiring
            TimeSpan normalUpdateInterval = new TimeSpan(leasePeriod.Ticks / 2);

            IDelayStrategy     speedupStrategy = new LinearSpeedupStrategy(normalUpdateInterval, MinimumLeaseRenewalInterval);
            ITaskSeriesCommand command         = new RenewLeaseCommand(leaseBlob, leaseId, lockId, speedupStrategy, _trace);

            return(new TaskSeriesTimer(command, exceptionHandler, Task.Delay(normalUpdateInterval)));
        }
    private static ITaskSeriesTimer CreateLeaseRenewalTimer(TimeSpan leasePeriod,
                                                            IDistributedLockManager distributedLockManager, IDistributedLock lockHandle, Func <bool> preExecuteCheck)
    {
        // renew the lease when it is halfway to expiring
        var            normalUpdateInterval = new TimeSpan(leasePeriod.Ticks / 2);
        IDelayStrategy speedupStrategy      =
            new LinearSpeedupStrategy(normalUpdateInterval, TimeSpan.FromMilliseconds(250));
        ITaskSeriesCommand command = new RenewLeaseCommand(distributedLockManager, lockHandle, speedupStrategy);

        return(new TaskSeriesTimer(command, Task.Delay(normalUpdateInterval), preExecuteCheck));
    }
Ejemplo n.º 5
0
        private ITaskSeriesTimer CreateUpdateMessageVisibilityTimer(QueueClient queue,
                                                                    QueueMessage message, TimeSpan visibilityTimeout,
                                                                    IWebJobsExceptionHandler exceptionHandler, Action <UpdateReceipt> onUpdateReceipt)
        {
            // Update a message's visibility when it is halfway to expiring.
            TimeSpan normalUpdateInterval = new TimeSpan(visibilityTimeout.Ticks / 2);

            IDelayStrategy     speedupStrategy = new LinearSpeedupStrategy(normalUpdateInterval, MinimumVisibilityRenewalInterval);
            ITaskSeriesCommand command         = new UpdateQueueMessageVisibilityCommand(queue, message, visibilityTimeout, speedupStrategy, onUpdateReceipt);

            return(new TaskSeriesTimer(command, exceptionHandler, Task.Delay(normalUpdateInterval)));
        }
        private static ITaskSeriesTimer CreateUpdateMessageVisibilityTimer(IStorageQueue queue,
                                                                           IStorageQueueMessage message, TimeSpan visibilityTimeout,
                                                                           IBackgroundExceptionDispatcher backgroundExceptionDispatcher)
        {
            // Update a message's visibility when it is halfway to expiring.
            TimeSpan normalUpdateInterval = new TimeSpan(visibilityTimeout.Ticks / 2);

            IDelayStrategy     speedupStrategy = new LinearSpeedupStrategy(normalUpdateInterval, TimeSpan.FromMinutes(1));
            ITaskSeriesCommand command         = new UpdateQueueMessageVisibilityCommand(queue, message, visibilityTimeout, speedupStrategy);

            return(new TaskSeriesTimer(command, backgroundExceptionDispatcher, Task.Delay(normalUpdateInterval)));
        }
 private ITaskSeriesTimer CreateTimer(IBackgroundExceptionDispatcher backgroundExceptionDispatcher)
 {
     return(LinearSpeedupStrategy.CreateTimer(_heartbeatCommand, HeartbeatIntervals.NormalSignalInterval,
                                              HeartbeatIntervals.MinimumSignalInterval, backgroundExceptionDispatcher));
 }
Ejemplo n.º 8
0
 private ITaskSeriesTimer CreateHeartbeatTimer(IWebJobsExceptionHandler exceptionHandler)
 {
     return(LinearSpeedupStrategy.CreateTimer(_heartbeatCommand, HeartbeatIntervals.NormalSignalInterval,
                                              HeartbeatIntervals.MinimumSignalInterval, exceptionHandler));
 }