Skip to content

Commit

Permalink
Merge pull request #8 from devsapp/add-fail-destination
Browse files Browse the repository at this point in the history
unzip fail can trigger dest fail function as a callback
  • Loading branch information
rsonghuster authored Jun 1, 2023
2 parents a40d1a1 + 5875c4c commit dbc35f1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion publish.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Type: Application
Name: start-unzip-oss
Version: 0.0.15
Version: 0.0.16
Provider:
- 阿里云
Description: 使用函数计算自动解压上传到OSS指定前缀目录的zip文件
Expand Down
10 changes: 10 additions & 0 deletions src/fail/index.py
Original file line number Diff line number Diff line change
@@ -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 {}
20 changes: 17 additions & 3 deletions src/s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit dbc35f1

Please sign in to comment.