Cloud Functions 函数概念:函数终止

发出信号来终止节点中的函数

代码示例

Node.js

如需向 Cloud Run functions 进行身份验证,请设置应用默认凭据。如需了解详情,请参阅为本地开发环境设置身份验证

// Await-ing promises within functions is OK if you don't return anything
await Promise.resolve();

// These will cause background tasks to stop executing immediately
return 1; // OK: returning a value

// These will wait until the related background task finishes
return Promise.resolve(); // OK: returning the promise itself
return await Promise.resolve(); // Same as above
return Promise.reject(); // OK: same behavior as to-be-resolved promises
return await Promise.reject(); // Same as above

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅 Google Cloud 示例浏览器