Skip to content

Commit

Permalink
fix: optimize outputs add configTrafficVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
yugasun committed Jul 1, 2020
1 parent b590d9d commit 5d09fb9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ inputs:
| eip | 否 | false | 固定出口 IP。默认为 false,即不启用 |
| tags | 否 | | 标签设置。可设置多对 key-value 的键值对 |
| events | 否 | | 触发器数组。支持以下几种触发器:timer(定时触发器)、apigw(网关触发器)、cos(COS 触发器)、cmq(CMQ Topic 触发器)、ckafka(CKafka 触发器)配置参数参考触发器。 |
| traffic | 否 | 1 | 配置默认流量中 `$LATEST` 版本比重,取值范围:0 ~ 1,比如 80%,可配置成 0.8。注意如果皮遏制灰度流量,需要配置对应的 API 网关触发器的 endpoints 的 `function.functionQualifier` 参数为 `$DEFAULT` (默认流量) |
| traffic | 否 | 1 | 配置默认流量中 `$LATEST` 版本比重,取值范围:0 ~ 1,比如 80%,可配置成 0.8。注意如果配置灰度流量,需要配置对应的 API 网关触发器的 endpoints 的 `function.functionQualifier` 参数为 `$DEFAULT` (默认流量) |

### 执行目录

Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"license": "Apache",
"dependencies": {
"download": "^8.0.0",
"tencent-component-toolkit": "^1.12.3",
"tencent-component-toolkit": "^1.12.4",
"type": "^2.0.0"
}
}
24 changes: 17 additions & 7 deletions src/serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,25 @@ class ServerlessComponent extends Component {
memorySize: scfOutput.MemorySize
}

if (scfOutput.LastVersion) {
outputs.lastVersion = scfOutput.LastVersion
this.state.lastVersion = scfOutput.LastVersion
// default version is $LATEST
outputs.lastVersion = scfOutput.LastVersion
? scfOutput.LastVersion
: this.state.lastVersion || '$LATEST'

// default traffic is 1.0, it can also be 0, so we should compare to undefined
outputs.traffic = scfOutput.Traffic
? scfOutput.Traffic
: this.state.traffic !== undefined
? this.state.traffic
: 1

if (outputs.traffic !== 1 && scfOutput.ConfigTrafficVersion) {
outputs.configTrafficVersion = scfOutput.ConfigTrafficVersion
this.state.configTrafficVersion = scfOutput.ConfigTrafficVersion
}

if (scfOutput.Traffic) {
outputs.traffic = scfOutput.Traffic
this.state.functionTraffic = scfOutput.Traffic
}
this.state.lastVersion = outputs.lastVersion
this.state.traffic = outputs.traffic

// handle apigw event outputs
if (existApigwTrigger) {
Expand Down

0 comments on commit 5d09fb9

Please sign in to comment.