如何在单个云函数中查找多个事件并在大查询中触发计划查询 [英] How can I look for multiple events in a single cloud function and trigger a schedule query in big query

查看:54
本文介绍了如何在单个云函数中查找多个事件并在大查询中触发计划查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题起源于我之前的帖子如何在另一个大型查询计划查询运行后立即运行大型查询计划查询

This question originated from my earlier post How to run a big query schedule query as soon as another big query schedule query has run

@guillaume blaquiere足够帮助我解决此问题.

@guillaume blaquiere was kind enough to help me resolve this issue.

但是,我还有另一个要求,在我之前的3个计划查询结束后,需要触发计划查询.因此,我将为每个计划查询创建pub子主题,并具有云功能来读​​取这些事件并触发另一个计划查询.但是,云功能只能读取一个事件,而不能读取多个事件.有什么方法可以处理这种情况,以便我的云功能可以从我之前的3个计划查询中读取所有3个事件,并且仅在完成所有3个计划查询后才触发新的计划查询.

However, I have a another requirement where I need to trigger a schedule query once my previous 3 schedule queries are over. So I am going to create pub sub topic for each of the schedule queries and have a cloud function to read these events and trigger another schedule query. However, cloud function can only read one event and not multiple events. Is there a way I can handle this scenario so that my cloud function will read all the 3 events from my 3 previous schedule queries and I trigger new schedule query only once all 3 schedule queries are done.

推荐答案

以前,我应该建议您使用Firestore记录接收到的消息以及收到的每条消息(在PubSub中发布的预定查询结束的消息))检查您是否收到了所有邮件(并继续该过程)(并停止并等待计划查询结束的下一条消息)

Previously, I should have recommended to you to use Firestore to log the received message, and at each message received (message of the end of scheduled query posted in PubSub) to check if you received all (and continue the process) or not (and stop and wait the next message of end of scheduled query)

但是,一个新产品已于6个月前发布,现已正式发布(GA): Google Workflows

However, a new product has been released 6 months ago and it is now Generally Available (GA): Google Workflows

该产品使您可以组织并按顺序排列所有操作.可以在单个位置监视和配置它们.当您必须链接多个动作时,这可能是一个很好的解决方案.您可以通过计划的工作流程(使用Cloud Scheduler触发工作流程),然后执行查询,等待查询结束,然后继续执行操作(您忘记了PubSub消息等).

This product allow you to organise and sequence all your action. To monitor and configure them in a single place. When you have to link several action, it could be a great solution. You can replace your scheduled queries, by a Scheduled Workflow (trigger the workflow with Cloud Scheduler) and then perform your query, wait the end of it, and continue your action (you forget the PubSub messages and so on).

要等待BigQuery工作,您可以从我的一位同事写的文章

To wait on BigQuery job, you can take inspiration from an article written by one of my colleague

因此,回到您的问题,当您设置工作流程处理而不是使用计划查询时,您可以想象并行触发多个工作流程,并由实验操作员等待所有完成.我刚刚发布了关于此的文章

So, to go back to your question, when you have set up a workflow processing instead of using schedule query, you can imagine triggering several workflow in parallel and wait all the completion with an experimental operator. I just released an article on this

这篇关于如何在单个云函数中查找多个事件并在大查询中触发计划查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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