小编ike*_*504的帖子

Google Cloud Function 未在 PubSub 上发布,超时

在 GCP(Google Cloud Platform)上,我有一个存储在云 SQL 上的数据库。

我有两个云功能:

  1. 向数据库发出请求(该请求可以有超过 1000 个结果),然后将结果发布到 PubSub
  2. 感谢 puppeteer 的网络抓取。

第一个云函数的代码:

//[Requirement]
const mysql = require('mysql')
const {SecretManagerServiceClient} = require('@google-cloud/secret-manager')
const ProjectID = process.env.secretID
const SqlPass = `projects/xxx`
const client = new SecretManagerServiceClient()
const {PubSub} = require('@google-cloud/pubsub');
const pubSubClient = new PubSub();
const topicName = "xxxxxx";
//[/Requirement]

exports.LaunchAudit = async () => {
    const dbSocketPath = "/cloudsql"
    const DB_USER = "xxx"
    const DB_PASS = await getSecret()
    const DB_NAME = "xxx"
    const CLOUD_SQL_CONNECTION_NAME = "xxx"
  
    //[SQL CONNEXION] …
Run Code Online (Sandbox Code Playgroud)

node.js google-cloud-platform google-cloud-pubsub

8
推荐指数
1
解决办法
6271
查看次数