云函数以Go语言触发Dataflow作业

huangapple go评论79阅读模式
英文:

Cloud Function to trigger a Dataflow job in Go

问题

我有一个使用Python SDK编写的Dataflow作业。但是我想使用Go编写的Cloud Functions来触发这个Dataflow作业。我找到了一个类似的线程,其中的函数是用Python编写的Trigger Dataflow with Python

我的流程如下:

  1. 使用PubSub通知来触发Cloud Functions。
  2. 使用Go编写的Cloud Functions来启动一个使用Python编写的DataFlow作业。

我可以将Dataflow SDK作为模板。有没有关于如何从Go触发Python Dataflow模板的指导?或者有没有更好的方法?

非常感谢!

英文:

I have a Dataflow job written using the Python SDK. But I want to trigger this Dataflow Job using Cloud Functions which should written in Go. I found a thread similar to this which has the function written in Python Trigger Dataflow with Python

My flow would be like below:

  1. PubSub Notification to trigger Cloud Functions
  2. Cloud Functions written in Go to start a DataFlow Job written in Python

I can make the Dataflow SDK as a template. Any pointers on how I can trigger the Python Dataflow templates from Go? Or is there a better way for it?

Many thanks!

答案1

得分: 3

检查 "google.golang.org/api/dataflow/v1b3" 包

我没有测试的方法,但我认为代码看起来像这样

ctx := context.Background()
dataflowService, _ := dataflow.NewService(ctx)
jobService := dataflow.NewProjectsJobsService(dataflowService)
jobService.Get("project", "job id").Do()
英文:

check "google.golang.org/api/dataflow/v1b3" package

I don't have a way to test it, but I think it looks like a code like this

ctx := context.Background()
dataflowService, _ := dataflow.NewService(ctx)
jobService := dataflow.NewProjectsJobsService(dataflowService)
jobService.Get("project ", "job id").Do()

huangapple
  • 本文由 发表于 2023年2月9日 07:29:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/75392729.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定