Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
More configurations here
https://github.com/serverless-components/tencent-scf/blob/master/docs/configure.md
Trigger the SCF from Cloud
Follow documents here https://github.com/TencentCloud/tencentcloud-sdk-nodejs
Here is my final version of code to trigger the SCF
const tencentcloud = require('tencentcloud-sdk-nodejs');
const ScfClient = tencentcloud.scf.v20180416.Client;
const models = tencentcloud.scf.v20180416.Models;
const Credential = tencentcloud.common.Credential;
const ClientProfile = tencentcloud.common.ClientProfile;
const HttpProfile = tencentcloud.common.HttpProfile;
const secretId = process.env.TENCENT_SECRET_ID || '';
const secretKey = process.env.TENCENT_SECRET_KEY || '';
const cred = new Credential(secretId, secretKey);
const httpProfile = new HttpProfile();
httpProfile.endpoint = "scf.tencentcloudapi.com";
const clientProfile = new ClientProfile();
clientProfile.httpProfile = httpProfile;
const client = new ScfClient(cred, "ap-shanghai", clientProfile);
class LambdaService {
/**
*
* @param {*} functionName eg: taskrunner
* @param {*} invocationType eg: Event
* @param {*} data eg: id1, id2, id3
*/
static async callRunner(functionName, invocationType, data) {
const request = new models.InvokeRequest();
const requstParams = '{"FunctionName":"' + functionName +
'","InvocationType":"' + invocationType +
'","ClientContext":' + JSON.stringify(JSON.stringify(data)) +
'}';
console.log('sending params: ' + requstParams);
request.from_json_string(requstParams);
await new Promise((resolve, reject) => {
client.Invoke(request, (err, res) => {
return void err ? reject(err) : resolve(res)
})
});
}
}
module.exports = LambdaService;
References:
https://cloud.tencent.com/document/api/583/17235
https://cloud.tencent.com/document/sdk/Node.js
https://github.com/TencentCloud/tencentcloud-sdk-nodejs/tree/master/tencentcloud/scf/v20180416
https://github.com/TencentCloud/tencentcloud-sdk-nodejs
https://cloud.tencent.com/document/api/583/17243
https://github.com/TencentCloud/tencentcloud-serverless-nodejs
https://cloud.tencent.com/document/product/583/37316
https://github.com/serverless-components/tencent-scf
分享到:
相关推荐
本文将深入探讨在PyPI官网上下载的`tencentcloud-sdk-python-scf-3.0.337.tar.gz`这一资源,该资源是腾讯云(Tencent Cloud)提供的Serverless Compute Function(简称SCF)的Python SDK,版本号为3.0.337。...
本文将详细解析名为"Tencentcloud-sdk-python-scf"的Python库,该库主要用于腾讯云的Serverless Compute服务(SCF,即Serverless函数计算)。版本为3.0.534,通过这个库,开发者可以轻松地与腾讯云SCF进行交互,实现...
本文将深入探讨名为"Tencentcloud-sdk-python-scf-3.0.396"的Python库,它是由腾讯云提供的,主要用于与Serverless Cloud Function (SCF) 服务进行交互。 首先,让我们了解什么是SCF。Serverless Cloud Function...
本文将深入探讨在PyPI官网上下载的"tencentcloud-sdk-python-scf-3.0.292.tar.gz"资源,该资源是针对腾讯云Serverless Cloud Function(SCF)的Python SDK。 首先,让我们理解"tencentcloud-sdk-python-scf"的含义...
- SCF(Serverless函数计算):无服务器运行环境,用于执行事件驱动的代码。 每个服务都有对应的SDK模块,通过这些模块,开发者可以方便地调用API,进行各种云服务的管理和操作。同时,TencentCloud SDK Python库还...
在本次讨论中,我们将聚焦于一个特定的包——tencentcloud-sdk-python-scf-3.0.515.tar.gz,这是腾讯云提供的Python SDK,专门用于与Serverless Cloud Function (SCF)服务进行交互。 SCF是腾讯云提供的无服务器计算...
描述在五分钟或更短的时间内引导一个新的Node.js Serverless项目。特征使用在下部署到 。 的包结构。 使用快速,可靠和安全的依赖项管理。 带有可配置选项和参数的示例,这些示例和参数由提供。 使用使用进行。 代码...
Serverless Design Patterns and Best Practices: Build, secure, and deploy enterprise ready serverless applications with AWS to improve developer productivity
serverless-nodejs-starter 具有Webpack,自定义域和单元测试支持的无服务器框架的Node.js入门 安装后,您可以在几分钟之内创建和部署具有最新ES6功能的功能,并加入棉绒和格式。 使用插件和 。 它支持: 处理...
amaysim /无服务器 包含NodeJS,Serverless Framework和Yarn的Docker映像。用法Docker运行命令 # running Serverless version 1.72.0$ docker run --rm amaysim/serverless:1.72.0 serverless --help在本地构建图像...
Serverless Web Applications with React and Firebase 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
快速开始 完成本指南中的步骤,以安装无服务器框架开源CLI并在腾讯云上部署示例服务,该服务向无服务器框架报告部署信息和操作指标。 ...npm install -g serverless 安装完成后,您应该能够从命令
The benefits of cloud-hosted serverless web apps are undeniable: lower complexity, quicker time to market, and easier scalability than traditional, server-dependent designs. And thanks to JavaScript ...
Serverless Architectures with AWS begins with an introduction to the serverless model and helps you get started with AWS and AWS Lambda. You'll also get to grips with other capabilities of the AWS ...
paced journey through building real-time applications with Firebase features such as Cloud Storage, Cloud Function, Hosting and the Realtime Database. We will learn how to secure our application by ...
在本地运行API网关使用serverless offline start 支持单元测试运行npm test以运行测试 正确错误消息的源映射 错误消息显示正确的行号 使用CloudWatch进行生产 使用ESLint整理代码 为您的阶段添加环境变量 无需管理...