如何使用 pubsub 模拟器在本地调用 firebase Schedule 函数 [英] How to invoke firebase Schedule functions locally using pubsub emulator

查看:22
本文介绍了如何使用 pubsub 模拟器在本地调用 firebase Schedule 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究云功能,尤其是日程安排功能.我需要每 5 分钟定期触发一个功能,但仅在测试步骤中.我需要在 pubsub 模拟器上运行它而不部署它.

I am working on cloud functions especially schedule functions. I need to trigger a function periodically each 5 minutes, but in only test step. I need to run it on pubsub emulator without deploying it.

怎么做?

我尝试使用 firebase shell,但它只触发了一次

I tried to use firebase shell, but it triggered only once

 exports.scheduledFunctionPlainEnglish =functions.pubsub.schedule('every 2 minutes')
 .onRun((context) => {
    functions.logger.log("this runs every 2 minutes")
    return null;
}) 

推荐答案

目前不支持计划函数.文档 声明:

This is currently not supported for scheduled functions. The documentation states:

使用 shell,您可以模拟数据并执行函数调用,以模拟与 Emulator Suite 当前不支持的产品的交互:存储、PubSub、分析、远程配置、存储、身份验证和 Crashlytics.

Using the shell, you mock data and perform function calls to simulate interaction with products that the Emulator Suite does not currently support: Storage, PubSub, Analytics, Remote Config, Storage, Auth, and Crashlytics.

计划函数是 pubsub 触发器的不受支持的扩展.

Scheduled functions are an unsupported extension of pubsub triggers.

随时向 Firebase 支持提出功能请求.

这篇关于如何使用 pubsub 模拟器在本地调用 firebase Schedule 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆