public HeartbeatFunctionExecutor(IRecurrentCommand heartbeatCommand,
     IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IFunctionExecutor innerExecutor)
 {
     _heartbeatCommand = heartbeatCommand;
     _backgroundExceptionDispatcher = backgroundExceptionDispatcher;
     _innerExecutor = innerExecutor;
 }
 public HeartbeatListener(IRecurrentCommand heartbeatCommand,
                          IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IListener innerListener)
 {
     _heartbeatCommand = heartbeatCommand;
     _innerListener    = innerListener;
     _timer            = CreateTimer(backgroundExceptionDispatcher);
 }
Пример #3
0
 public HeartbeatFunctionExecutor(IRecurrentCommand heartbeatCommand,
                                  IWebJobsExceptionHandler exceptionHandler, IFunctionExecutor innerExecutor)
 {
     _heartbeatCommand = heartbeatCommand;
     _exceptionHandler = exceptionHandler;
     _innerExecutor    = innerExecutor;
 }
Пример #4
0
 public static ITaskSeriesTimer CreateTimer(IRecurrentCommand command, TimeSpan initialInterval,
     TimeSpan delayInterval, IBackgroundExceptionDispatcher backgroundExceptionDispatcher)
 {
     IDelayStrategy delayStrategy = new FixedDelayStrategy(delayInterval);
     ITaskSeriesCommand timerCommand = new RecurrentTaskSeriesCommand(command, delayStrategy);
     return new TaskSeriesTimer(timerCommand, backgroundExceptionDispatcher, Task.Delay(initialInterval));
 }
Пример #5
0
 public HeartbeatListener(IRecurrentCommand heartbeatCommand,
                          IWebJobsExceptionHandler exceptionHandler, IListener innerListener)
 {
     _heartbeatCommand = heartbeatCommand;
     _innerListener    = innerListener;
     _timer            = CreateTimer(exceptionHandler);
 }
Пример #6
0
        private async Task ExecuteWithOutputLogsAsync(IFunctionInstance instance,
                                                      IReadOnlyDictionary <string, IValueProvider> parameters,
                                                      TextWriter consoleOutput,
                                                      IFunctionOutputDefinition outputDefinition,
                                                      IDictionary <string, ParameterLog> parameterLogCollector,
                                                      CancellationToken cancellationToken)
        {
            IFunctionInvoker invoker = instance.Invoker;
            IReadOnlyDictionary <string, IWatcher> watches = CreateWatches(parameters);
            IRecurrentCommand updateParameterLogCommand    =
                outputDefinition.CreateParameterLogUpdateCommand(watches, consoleOutput);

            using (ITaskSeriesTimer updateParameterLogTimer = StartParameterLogTimer(updateParameterLogCommand,
                                                                                     _backgroundExceptionDispatcher))
            {
                try
                {
                    await ExecuteWithWatchersAsync(invoker, parameters, cancellationToken);

                    if (updateParameterLogTimer != null)
                    {
                        // Stop the watches after calling IValueBinder.SetValue (it may do things that should show up in
                        // the watches).
                        // Also, IValueBinder.SetValue could also take a long time (flushing large caches), and so it's
                        // useful to have watches still running.
                        await updateParameterLogTimer.StopAsync(cancellationToken);
                    }
                }
                finally
                {
                    ValueWatcher.AddLogs(watches, parameterLogCollector);
                }
            }
        }
 public static ITaskSeriesTimer CreateTimer(IRecurrentCommand command, TimeSpan normalInterval,
     TimeSpan minimumInterval, IBackgroundExceptionDispatcher backgroundExceptionDispatcher)
 {
     IDelayStrategy delayStrategy = new LinearSpeedupStrategy(normalInterval, minimumInterval);
     ITaskSeriesCommand timerCommand = new RecurrentTaskSeriesCommand(command, delayStrategy);
     return new TaskSeriesTimer(timerCommand, backgroundExceptionDispatcher, Task.Delay(normalInterval));
 }
Пример #8
0
 public HeartbeatFunctionExecutor(IRecurrentCommand heartbeatCommand,
                                  IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IFunctionExecutor innerExecutor)
 {
     _heartbeatCommand = heartbeatCommand;
     _backgroundExceptionDispatcher = backgroundExceptionDispatcher;
     _innerExecutor = innerExecutor;
 }
 public HeartbeatListener(IRecurrentCommand heartbeatCommand,
     IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IListener innerListener)
 {
     _heartbeatCommand = heartbeatCommand;
     _innerListener = innerListener;
     _timer = CreateTimer(backgroundExceptionDispatcher);
 }
        public static ITaskSeriesTimer CreateTimer(IRecurrentCommand command, TimeSpan normalInterval,
                                                   TimeSpan minimumInterval, IWebJobsExceptionHandler exceptionHandler)
        {
            IDelayStrategy     delayStrategy = new LinearSpeedupStrategy(normalInterval, minimumInterval);
            ITaskSeriesCommand timerCommand  = new RecurrentTaskSeriesCommand(command, delayStrategy);

            return(new TaskSeriesTimer(timerCommand, exceptionHandler, Task.Delay(normalInterval)));
        }
        public static ITaskSeriesTimer CreateTimer(IRecurrentCommand command, TimeSpan normalInterval,
                                                   TimeSpan minimumInterval, IBackgroundExceptionDispatcher backgroundExceptionDispatcher)
        {
            IDelayStrategy     delayStrategy = new LinearSpeedupStrategy(normalInterval, minimumInterval);
            ITaskSeriesCommand timerCommand  = new RecurrentTaskSeriesCommand(command, delayStrategy);

            return(new TaskSeriesTimer(timerCommand, backgroundExceptionDispatcher, Task.Delay(normalInterval)));
        }
Пример #12
0
        public static ITaskSeriesTimer CreateTimer(IRecurrentCommand command, TimeSpan initialInterval,
                                                   TimeSpan delayInterval, IWebJobsExceptionHandler exceptionHandler)
        {
            IDelayStrategy     delayStrategy = new FixedDelayStrategy(delayInterval);
            ITaskSeriesCommand timerCommand  = new RecurrentTaskSeriesCommand(command, delayStrategy);

            return(new TaskSeriesTimer(timerCommand, exceptionHandler, Task.Delay(initialInterval)));
        }
        internal static IListener CreateHostListener(IListenerFactory allFunctionsListenerFactory, SharedQueueHandler sharedQueue,
                                                     IRecurrentCommand heartbeatCommand, IWebJobsExceptionHandler exceptionHandler, CancellationToken shutdownToken)
        {
            IListener factoryListener   = new ListenerFactoryListener(allFunctionsListenerFactory, sharedQueue);
            IListener heartbeatListener = new HeartbeatListener(heartbeatCommand, exceptionHandler, factoryListener);
            IListener shutdownListener  = new ShutdownListener(shutdownToken, heartbeatListener);

            return(shutdownListener);
        }
        private static IListener CreateHostListener(IListenerFactory allFunctionsListenerFactory,
                                                    IRecurrentCommand heartbeatCommand, IBackgroundExceptionDispatcher backgroundExceptionDispatcher,
                                                    CancellationToken shutdownToken)
        {
            IListener factoryListener   = new ListenerFactoryListener(allFunctionsListenerFactory);
            IListener heartbeatListener = new HeartbeatListener(heartbeatCommand, backgroundExceptionDispatcher, factoryListener);
            IListener shutdownListener  = new ShutdownListener(shutdownToken, heartbeatListener);

            return(shutdownListener);
        }
        private static IFunctionExecutor CreateHostCallExecutor(IListenerFactory instanceQueueListenerFactory,
                                                                IRecurrentCommand heartbeatCommand, IBackgroundExceptionDispatcher backgroundExceptionDispatcher,
                                                                CancellationToken shutdownToken, IFunctionExecutor innerExecutor)
        {
            IFunctionExecutor heartbeatExecutor = new HeartbeatFunctionExecutor(heartbeatCommand,
                                                                                backgroundExceptionDispatcher, innerExecutor);
            IFunctionExecutor abortListenerExecutor    = new AbortListenerFunctionExecutor(instanceQueueListenerFactory, heartbeatExecutor);
            IFunctionExecutor shutdownFunctionExecutor = new ShutdownFunctionExecutor(shutdownToken, abortListenerExecutor);

            return(shutdownFunctionExecutor);
        }
        internal static IFunctionExecutor CreateHostCallExecutor(IListenerFactory instanceQueueListenerFactory,
                                                                 IRecurrentCommand heartbeatCommand, IWebJobsExceptionHandler exceptionHandler,
                                                                 CancellationToken shutdownToken, IFunctionExecutor innerExecutor)
        {
            IFunctionExecutor heartbeatExecutor = new HeartbeatFunctionExecutor(heartbeatCommand,
                                                                                exceptionHandler, innerExecutor);
            IFunctionExecutor abortListenerExecutor    = new AbortListenerFunctionExecutor(instanceQueueListenerFactory, heartbeatExecutor);
            IFunctionExecutor shutdownFunctionExecutor = new ShutdownFunctionExecutor(shutdownToken, abortListenerExecutor);

            return(shutdownFunctionExecutor);
        }
        private static ITaskSeriesTimer StartOutputTimer(IRecurrentCommand updateCommand, IBackgroundExceptionDispatcher backgroundExceptionDispatcher)
        {
            if (updateCommand == null)
            {
                return(null);
            }

            TimeSpan         initialDelay = FunctionOutputIntervals.InitialDelay;
            TimeSpan         refreshRate  = FunctionOutputIntervals.RefreshRate;
            ITaskSeriesTimer timer        = FixedDelayStrategy.CreateTimer(updateCommand, initialDelay, refreshRate, backgroundExceptionDispatcher);

            timer.Start();

            return(timer);
        }
        private static ITaskSeriesTimer StartParameterLogTimer(IRecurrentCommand updateCommand, IWebJobsExceptionHandler exceptionHandler)
        {
            if (updateCommand == null)
            {
                return(null);
            }

            TimeSpan         initialDelay = FunctionParameterLogIntervals.InitialDelay;
            TimeSpan         refreshRate  = FunctionParameterLogIntervals.RefreshRate;
            ITaskSeriesTimer timer        = FixedDelayStrategy.CreateTimer(updateCommand, initialDelay, refreshRate, exceptionHandler);

            timer.Start();

            return(timer);
        }
Пример #19
0
        private async Task ExecuteWithLoggingAsync(IFunctionInstance instance,
                                                   IReadOnlyDictionary <string, IValueProvider> parameters,
                                                   TraceWriter trace,
                                                   ILogger logger,
                                                   IFunctionOutputDefinition outputDefinition,
                                                   IDictionary <string, ParameterLog> parameterLogCollector,
                                                   TraceLevel functionTraceLevel,
                                                   CancellationTokenSource functionCancellationTokenSource)
        {
            IFunctionInvoker invoker = instance.Invoker;

            IReadOnlyDictionary <string, IWatcher> parameterWatchers = null;
            ITaskSeriesTimer updateParameterLogTimer = null;

            if (functionTraceLevel >= TraceLevel.Info)
            {
                parameterWatchers = CreateParameterWatchers(parameters);
                IRecurrentCommand updateParameterLogCommand = outputDefinition.CreateParameterLogUpdateCommand(parameterWatchers, trace, logger);
                updateParameterLogTimer = StartParameterLogTimer(updateParameterLogCommand, _exceptionHandler);
            }

            try
            {
                await ExecuteWithWatchersAsync(instance, parameters, trace, logger, functionCancellationTokenSource);

                if (updateParameterLogTimer != null)
                {
                    // Stop the watches after calling IValueBinder.SetValue (it may do things that should show up in
                    // the watches).
                    // Also, IValueBinder.SetValue could also take a long time (flushing large caches), and so it's
                    // useful to have watches still running.
                    await updateParameterLogTimer.StopAsync(functionCancellationTokenSource.Token);
                }
            }
            finally
            {
                if (updateParameterLogTimer != null)
                {
                    ((IDisposable)updateParameterLogTimer).Dispose();
                }

                if (parameterWatchers != null)
                {
                    ValueWatcher.AddLogs(parameterWatchers, parameterLogCollector);
                }
            }
        }
 private static IListener CreateHostListener(IListenerFactory allFunctionsListenerFactory,
     IRecurrentCommand heartbeatCommand, IBackgroundExceptionDispatcher backgroundExceptionDispatcher,
     CancellationToken shutdownToken)
 {
     IListener factoryListener = new ListenerFactoryListener(allFunctionsListenerFactory);
     IListener heartbeatListener = new HeartbeatListener(heartbeatCommand, backgroundExceptionDispatcher, factoryListener);
     IListener shutdownListener = new ShutdownListener(shutdownToken, heartbeatListener);
     return shutdownListener;
 }
 public RecurrentTaskSeriesCommand(IRecurrentCommand innerCommand, IDelayStrategy delayStrategy)
 {
     _innerCommand = innerCommand;
     _delayStrategy = delayStrategy;
 }
 private static IFunctionExecutor CreateHostCallExecutor(IListenerFactory instanceQueueListenerFactory,
     IRecurrentCommand heartbeatCommand, IBackgroundExceptionDispatcher backgroundExceptionDispatcher,
     CancellationToken shutdownToken, IFunctionExecutor innerExecutor)
 {
     IFunctionExecutor heartbeatExecutor = new HeartbeatFunctionExecutor(heartbeatCommand,
         backgroundExceptionDispatcher, innerExecutor);
     IFunctionExecutor abortListenerExecutor = new AbortListenerFunctionExecutor(instanceQueueListenerFactory, heartbeatExecutor);
     IFunctionExecutor shutdownFunctionExecutor = new ShutdownFunctionExecutor(shutdownToken, abortListenerExecutor);
     return shutdownFunctionExecutor;
 }
Пример #23
0
 public RecurrentTaskSeriesCommand(IRecurrentCommand innerCommand, IDelayStrategy delayStrategy)
 {
     _innerCommand  = innerCommand;
     _delayStrategy = delayStrategy;
 }