云应用
Serverless 云应用(Serverless Cloud App)是云开发提供的一种无服务器容器服务,用户可面向代码/镜像等多种方式使用。无需维护复杂的容器环境,可专注于自身的业务,一键开通后即可享受能自动扩缩容的容器资源。 在 Serverless 云应用中,用户同时可享受云开发提供的其他相应开发能力与 SDK ,以及云开发自带的默认域名用于服务端业务访问。
tip
以下所有接口添加于 3.6.0+ 版本
#
调整服务版本流量配置#
1. 接口描述接口功能:调整服务版本流量配置。
接口声明:async modifyServerFlow(options: IModifyServerFlowOption)
#
2. 输入参数字段 | 必填 | 类型 | 说明 |
---|---|---|---|
serverName | 是 | String | 服务名称 |
versionFlowItems | 否 | Array<ICloudBaseRunVersionFlowItem> | 流量占比 |
#
ICloudBaseRunVersionFlowItem字段 | 必填 | 类型 | 说明 |
---|---|---|---|
versionName | 是 | String | 版本名称 |
flowRatio | 是 | Number | 流量占比 |
#
3. 返回结果字段 | 必填 | 类型 | 说明 |
---|---|---|---|
RequestId | 是 | String | 请求唯一标识 |
Result | 是 | String | 返回结果,succ 代表成功 |
#
4. 示例代码import CloudBase from "@cloudbase/manager-node";
const app = new CloudBase({ secretId: "Your SecretId", secretKey: "Your SecretKey", envId: "Your envId" // 云开发环境ID,可在腾讯云云开发控制台获取});
async function test() { const res = await app.cloudApp.modifyServerFlow({ serverName: "test", versionFlowItems: [ { versionName: "test-001", flowRatio: 30 }, { versionName: "test-002", flowRatio: 70 } ] }); const { Result } = res; console.log(Result === "succ");}
test();