当前位置:网站首页>Decryption function calculates "task state and lifecycle management" of asynchronous task capability
Decryption function calculates "task state and lifecycle management" of asynchronous task capability
2022-07-04 19:53:00 【InfoQ】
Preface
Management of task status and life cycle
Task status management


- After the user triggers a task , Task in the team , Changed to: Enqueued state , And return trigger success ;
- The task is queued in the back-end service of function calculation , The task becomes Dequeued state ;
- The backend will check the task configuration . If
- The asynchronous message validity function is configured , And the difference between the time of leaving the team and the time of joining the team has exceeded the validity period , Then the task is discarded , Changed to: Expired state . Task to terminate ;
- The function corresponding to the task has been deleted , Or there is an error creating the instance , Then discard the message , The task is changed to Invalid state ;
- After the inspection, the task officially enters Running state . At this time, the task has triggered the actual execution ;
- When the task is completed , According to the return, it will change to the following states :
- Retrying: The user has configured the number of retries ( The default is 3), And the task execution failed , At this time, it will enter the retry state , Then it will be changed to Running state ;
- Failed: Task execution failed , And the number of retries has exceeded . The task status will be changed to Failed;
- Succeeded: The task was executed successfully .
- If the user triggers during the whole state flow Cancel, Then the task will be changed to Stopping state , And try to stop the task . When the task stops successfully , Mission entry Stopped state .
Task runtime management and life cycle

- The creation is complete -> Execute request phase : Support Initializer function , Support initializing instance operations . Users can configure such as global variables 、 Connection pool initialization and other related operations ;
- In execution -> After execution Pause example : Support PreFreeze Interface , Support in function Pause Execute user-defined logic before the instance ;
- In execution -> external cancel: Function evaluation will force Restart User instance , stay Restart Pre support PreStop Interface . The user can configure the logic of graceful stop , To support Cancel Custom behavior when ;
- After completion Pause -> Destroy instance : When there is no request for a period of time , Function calculation will destroy the instance . This will call PreStop Interface , Users can configure the behavior of destroying containers ( Such as closing the connection pool ).

Stop the task
import fc "github.com/aliyun/fc-go-sdk"
func CancelJob() {
stopInput := fc.NewStopStatefulAsyncInvocationInput("ServiceName", "FunctionName", "TaskUUID")
output, err := fcClient.StopStatefulAsyncInvocation(stopInput)
...
}
summary


边栏推荐
- 矩阵翻转(数组模拟)
- Multi table operation inner join query
- Educational Codeforces Round 22 E. Army Creation
- Explicit random number
- . Net ORM framework hisql practice - Chapter 2 - using hisql to realize menu management (add, delete, modify and check)
- Niuke Xiaobai month race 7 F question
- 数据集划分
- HMM隐马尔可夫模型最详细讲解与代码实现
- c# . Net MVC uses Baidu ueditor rich text box to upload files (pictures, videos, etc.)
- Upgrade the smart switch, how much is the difference between the "zero fire version" and "single fire" wiring methods?
猜你喜欢
如何使用Async-Awati异步任务处理代替BackgroundWorker?
Euler function
YOLOv5s-ShuffleNetV2
记一次 .NET 某工控数据采集平台 线程数 爆高分析
The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize
Cbcgptabwnd control used by BCG (equivalent to MFC TabControl)
Niuke Xiaobai month race 7 who is the divine Archer
华为nova 10系列支持应用安全检测功能 筑牢手机安全防火墙
BCG 使用之新建向导效果
Detailed explanation of the binary processing function threshold() of opencv
随机推荐
Find the nth power of 2
Kotlin cycle control
Niuke Xiaobai monthly race 7 I new Microsoft Office Word document
Data set division
数据集划分
【问题】druid报异常sql injection violation, part alway true condition not allow 解决方案
Cbcgpprogressdlg progress bar used by BCG
黑马程序员-软件测试--08阶段2-linux和数据库-23-30-进程端口相关,修改文件权限,端口号信息的获取,程序和进程相关操作,linux命令案例
Functional interface
Kotlin classes and objects
What should we pay attention to when doing social media marketing? Here is the success secret of shopline sellers!
@transactional滥用导致数据源连接池耗尽问题
C # use stopwatch to measure the running time of the program
@Data source connection pool exhaustion caused by transactional abuse
双冒号作用运算符以及命名空间详解
PolyFit软件介绍
How to use async Awati asynchronous task processing instead of backgroundworker?
Abc229 summary (connected component count of the longest continuous character graph in the interval)
Double colon function operator and namespace explanation
1002. A+B for Polynomials (25)(PAT甲级)