调用活动函数后,持久函数会如何处理? [英] What happens to Durable Functions After Activity Function gets called?

查看:59
本文介绍了调用活动函数后,持久函数会如何处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我在持久性函数中意识到,当调用活动函数时,当前的持久性函数实际上会停止并等待重新开始.我的问题是原始持久功能如何退出?我已经进行了一些调试,并且没有引发异常,也没有返回任何值.它如何退出?

So I'm aware in durable functions that when an activity function gets called, the current durable function essentially stops and it waits to start over. My question is how does the original durable function exit? I've done some debugging, and no exception is thrown nor is a value returned. How does it exit?

   [FunctionName("DurableFunction")]
    public static async Task Durable([OrchestrationTrigger] IDurableOrchestrationContext context, ILogger log)
    {
        try
        {
            using (DisposeObject t = new DisposeObject("We created a new context", log))
            {
                string s = context.GetInput<string>();
                string result = await context.CallActivityAsync<string>("ActivityFunction", s);
                log.LogInformation(result);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }
        finally
        {
            Console.WriteLine("When does this get hit?");
        }
    }

例如,在此示例中,是否要丢弃一次性物品直到结束?有什么方法可以检查我们何时启动新功能?

For example, in this example, do disposable object never gets disposed until the end? Is there a way to check when we start a new function?

推荐答案

编排函数应为某种无状态".他们应该管理和编排活动(和子编排)的流程,但不要执行任何动作或任何IO自己调用.拥有需要处置的对象表示某种非托管资源或IO绑定资源.在编排功能中,这两者都是不可行的".

Orchestration functions should be some kind of 'stateless'. They should manage and orchestrate the flow of activities (and sub orchestrations) but never perform actions or any IO calls themselves. Having an object that needs disposal indicates either some kind of unmanaged resources or IO bound resources. Which are both a 'no-go' in an orchestration function.

(这可能不会从技术上回答您的问题,但希望可以帮助您以一种不错的方式设计它们.)

(That might not answer your question technically but hopefully helps you designing them in a good way.)

这篇关于调用活动函数后,持久函数会如何处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆