@faasjs/cloud_function

License: MITopen in new windowNPM Stable Versionopen in new windowNPM Beta Versionopen in new window

A FaasJS plugin, let function could create, config and invoke CloudFunction.

Install

npm install @faasjs/cloud_function

Modules

Classes

Type aliases

Functions

Type aliases

CloudFunctionAdapter

Ƭ CloudFunctionAdapter: Object

Type declaration

NameType
invokeCloudFunction(name: string, data: any, options?: any) => Promise<void>
invokeSyncCloudFunction<TResult>(name: string, data: any, options?: any) => Promise<TResult>

CloudFunctionConfig

Ƭ CloudFunctionConfig: Object

云函数配置项

Index signature

▪ [key: string]: any

Type declaration

NameTypeDescription
config?{ [key: string]: any; memorySize?: 64 | 128 | 256 | 384 | 512 | 640 | 768 | 896 | 1024 | number ; name?: string ; provisionedConcurrent?: { executions: number } ; timeout?: number ; triggers?: { name?: string ; type: "timer" | string ; value: string }[] }配置项
config.memorySize?64 | 128 | 256 | 384 | 512 | 640 | 768 | 896 | 1024 | number内存大小,单位为MB,默认 64
config.name?string配置名称
config.provisionedConcurrent?{ executions: number }预制并发配置
config.provisionedConcurrent.executionsnumber预制并发数量
config.timeout?number执行超时时间,单位为秒,默认 30
config.triggers?{ name?: string ; type: "timer" | string ; value: string }[]触发器配置
name?string插件名称
validator?{ event?: ValidatorConfig }-
validator.event?ValidatorConfig-

Functions

invoke

invoke<TData>(name, data?, options?): Promise<void>

异步触发云函数

Type parameters

NameType
TDataany

Parameters

NameTypeDescription
namestring云函数文件名或云函数名
data?TData参数
options?Object额外配置项

Returns

Promise<void>


invokeSync

invokeSync<TResult, TData>(name, data?, options?): Promise<TResult>

同步触发云函数

Type parameters

NameType
TResultany
TDataany

Parameters

NameTypeDescription
namestring云函数文件名或云函数名
data?TData参数
options?Object额外配置项

Returns

Promise<TResult>


useCloudFunction

useCloudFunction(config?): CloudFunction & UseifyPlugin

Parameters

NameType
config?CloudFunctionConfig | () => CloudFunctionConfig

Returns

CloudFunction & UseifyPlugin