不会在天蓝色函数上安装无限的监视器,也不会创建无限量的重播吗?

时间:2019-05-08 12:04:29

标签: azure azure-functions

我正在学习天蓝色函数和持久函数。查看监视器模式的示例:

https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-monitor

public static async Task Run(DurableOrchestrationContext monitorContext, ILogger log)
{
    MonitorRequest input = monitorContext.GetInput<MonitorRequest>();
    if (!monitorContext.IsReplaying) { log.LogInformation($"Received monitor request. Location: {input?.Location}. Phone: {input?.Phone}."); }

    VerifyRequest(input);

    DateTime endTime = monitorContext.CurrentUtcDateTime.AddHours(6);
    if (!monitorContext.IsReplaying) { log.LogInformation($"Instantiating monitor for {input.Location}. Expires: {endTime}."); }

    while (monitorContext.CurrentUtcDateTime < endTime)
    {
        // Check the weather
        if (!monitorContext.IsReplaying) { log.LogInformation($"Checking current weather conditions for {input.Location} at {monitorContext.CurrentUtcDateTime}."); }

        bool isClear = await monitorContext.CallActivityAsync<bool>("E3_GetIsClear", input.Location);

        if (isClear)
        {
            // It's not raining! Or snowing. Or misting. Tell our user to take advantage of it.
            if (!monitorContext.IsReplaying) { log.LogInformation($"Detected clear weather for {input.Location}. Notifying {input.Phone}."); }

            await monitorContext.CallActivityAsync("E3_SendGoodWeatherAlert", input.Phone);
            break;
        }
        else
        {
            // Wait for the next checkpoint
            var nextCheckpoint = monitorContext.CurrentUtcDateTime.AddMinutes(30);
            if (!monitorContext.IsReplaying) { log.LogInformation($"Next check for {input.Location} at {nextCheckpoint}."); }

            await monitorContext.CreateTimer(nextCheckpoint, CancellationToken.None);
        }
    }

    log.LogInformation("Monitor expiring.");
}
  1. 是否已将其更改为无限显示器?
  2. 难道情境增长的历史会引起问题吗?
  3. 我是否纠正为,只要有一个调用等待CreateTimer,则当前方法会一直等到计时器满足时,但在计时器触发时也会执行重播?
  4. 那下次,又有什么方法运行初始方法+ 2次重播?
  5. 如果平台将功能移至新主机,会否取消该初始方法,并且由于在新主机上播放重播而继续执行,会发生什么情况?

0 个答案:

没有答案