From 5875c4cecbfdacad0baad5e14602b98d017d87df Mon Sep 17 00:00:00 2001 From: rsonghuster Date: Thu, 1 Jun 2023 10:01:18 +0800 Subject: [PATCH] unzip fail can trigger dest fail function as a callback --- publish.yaml | 2 +- src/fail/index.py | 10 ++++++++++ src/s.yaml | 20 +++++++++++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 src/fail/index.py diff --git a/publish.yaml b/publish.yaml index 2db6bae..8d8a0c5 100644 --- a/publish.yaml +++ b/publish.yaml @@ -1,6 +1,6 @@ Type: Application Name: start-unzip-oss -Version: 0.0.15 +Version: 0.0.16 Provider: - 阿里云 Description: 使用函数计算自动解压上传到OSS指定前缀目录的zip文件 diff --git a/src/fail/index.py b/src/fail/index.py new file mode 100644 index 0000000..b3e86ac --- /dev/null +++ b/src/fail/index.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +import logging + + +def handler(event, context): + logger = logging.getLogger() + logger.info('destnation fail: {}'.format(event)) + # do your things + # ... + return {} diff --git a/src/s.yaml b/src/s.yaml index 7b593a8..73d013c 100644 --- a/src/s.yaml +++ b/src/s.yaml @@ -46,9 +46,9 @@ services: RETAIN_FILE_NAME: "{{ retainFileName }}" # 如果是很大的 ZIP 文件, 想使用异步调用,可以开启如下配置, 将每次函数调用看做一个任务执行 asyncConfiguration: - # destination: - # onSuccess: acs:fc:::services/${vars.service.name}/functions/dest-succ - # onFailure: acs:fc:::services/${vars.service.name}/functions/dest-fail + destination: + # onSuccess: acs:fc:::services/${vars.service.name}/functions/dest-succ + onFailure: acs:fc:::services/${vars.service.name}/functions/dest-fail maxAsyncEventAgeInSeconds: 7200 maxAsyncRetryAttempts: 3 statefulInvocation: true @@ -67,3 +67,17 @@ services: Prefix: "{{ prefix }}" Suffix: .zip bucketName: "{{ bucketName }}" + + dest-fail: + component: fc + props: + region: ${vars.region} + service: ${vars.service} + function: + name: dest-fail + description: "async task destination fail function by serverless devs" + runtime: python3 + codeUri: ./fail + handler: index.handler + memorySize: 512 + timeout: 60