Skip to content

Commit

Permalink
feat(scf): cli createfunction support sfType
Browse files Browse the repository at this point in the history
  • Loading branch information
wangpand0508 committed Jun 1, 2023
1 parent e91c2ec commit 374450b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tencent-component-toolkit",
"version": "2.24.2",
"version": "2.24.3",
"description": "Tencent component toolkit",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
30 changes: 25 additions & 5 deletions src/modules/scf/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface FunctionCode {
RegistryId?: string;
Command?: string;
Args?: string;
ContainerImageAccelerate?: boolean;
};
}

Expand Down Expand Up @@ -67,6 +68,13 @@ export interface BaseFunctionConfig {
ProtocolParams?: ProtocolParams;
NodeType?: string;
NodeSpec?: string;
SFType?: string;
GpuReservedQuota?: number;
// 请求并发
InstanceConcurrencyConfig?: {
DynamicEnabled?: boolean;
MaxConcurrency?: number;
};
}

export interface TriggerType {
Expand Down Expand Up @@ -228,6 +236,8 @@ export interface ScfCreateFunctionInputs {
command?: string;
// 启动命令参数
args?: string;
// 镜像加速
containerImageAccelerate?: boolean;
};

// 异步调用重试配置
Expand All @@ -236,6 +246,16 @@ export interface ScfCreateFunctionInputs {

protocolType?: string;
protocolParams?: ProtocolParams;

// sd应用类型
sFType?: string;
// gpu并发数,默认是0
gpuReservedQuota?: number;
// 请求并发配置
instanceConcurrencyConfig?: {
dynamicEnabled?: boolean;
maxConcurrency?: number;
};
}

export interface ScfUpdateAliasTrafficInputs {
Expand Down Expand Up @@ -391,25 +411,25 @@ export interface GetRequestStatusOptions {
/**
* 函数名称
*/
functionName: string
functionName: string;

/**
* 需要查询状态的请求id
*/
functionRequestId: string
functionRequestId: string;

/**
* 函数的所在的命名空间
*/
namespace?: string
namespace?: string;

/**
* 查询的开始时间,例如:2017-05-16 20:00:00,不填默认为当前时间 - 15min
*/
startTime?: string
startTime?: string;

/**
* 查询的结束时间,例如:2017-05-16 20:59:59,不填默认为当前时间。EndTime 需要晚于 StartTime。
*/
endTime?: string
endTime?: string;
}
21 changes: 21 additions & 0 deletions src/modules/scf/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export const formatInputs = (inputs: ScfCreateFunctionInputs) => {
if (imageConfig.args) {
functionInputs.Code!.ImageConfig!.Args = imageConfig.args;
}

if (imageConfig?.containerImageAccelerate !== undefined) {
functionInputs.Code!.ImageConfig!.ContainerImageAccelerate =
imageConfig?.containerImageAccelerate;
}
} else {
// 基于 COS 代码部署
functionInputs.Code = {
Expand Down Expand Up @@ -85,6 +90,22 @@ export const formatInputs = (inputs: ScfCreateFunctionInputs) => {
}
}

// sd应用类型
if (inputs?.sFType) {
functionInputs.SFType = inputs?.sFType;
}
// sd gpu并发数
if (inputs?.gpuReservedQuota) {
functionInputs.GpuReservedQuota = inputs?.gpuReservedQuota;
}
// 请求并发
if (inputs?.instanceConcurrencyConfig) {
functionInputs.InstanceConcurrencyConfig = {
DynamicEnabled: inputs?.instanceConcurrencyConfig?.dynamicEnabled,
MaxConcurrency: inputs?.instanceConcurrencyConfig?.maxConcurrency,
};
}

if (inputs.role) {
functionInputs.Role = inputs.role;
}
Expand Down

0 comments on commit 374450b

Please sign in to comment.