云调度程序 - Terrafrom - 如何在 CloudSheduler 主体中传递当前日期

发布于 2025-01-16 06:24:31 字数 800 浏览 3 评论 0 原文

我使用 cloudScheduler 来安排数据流作业。我需要使用 cloudsheduler 主体将运行日期/运行时/当前日期动态传递给数据流作业。 正在使用数据流作业代码中的 Java 选项读取主体参数。

寻找语法来读取 cloudschduler body 中的标头 X-CloudScheduler-ScheduleTime

body = base64encode(<<-EOT { "jobName": "${each.value.name}_${http_target.h}", “参数”: { "bigtableInstanceId": "${var.cloudscheduler_bigtable_instanceid}", "bigtableProjectId": "${var.project_id}", "bigtableTableId": "${each.value.bigtableTableId}", "inputFilePattern": "${each.value.inputFilePattern}", “运行日期”:?????????
“区域”:“${var.cloudscheduler_region}”, }, “环境”: { “工人数量”:“2”, "tempLocation": "gs://gcslocation/temp2", "zone": "${var.cloudscheduler_region}-a" } } 环氧乙烷 ) 如何

在我们在数据流作业代码中读取的cloudscheduler主体“runningdate”:?????????中传递计划日期/运行日期。

Am using cloudScheduler to schedule the dataflow job. Where i need to pass the rundate/runtime/current date dynamically to dataflow job using cloudsheduler body.
Am reading the body parameters using Java Options in Dataflow job code.

Looking for syntax to read header X-CloudScheduler-ScheduleTime in cloudschduler body

body = base64encode(<<-EOT
{
"jobName": "${each.value.name}_${http_target.h}",
"parameters": {
"bigtableInstanceId": "${var.cloudscheduler_bigtable_instanceid}",
"bigtableProjectId": "${var.project_id}",
"bigtableTableId": "${each.value.bigtableTableId}",
"inputFilePattern": "${each.value.inputFilePattern}",
"runningdate" :????????
"region": "${var.cloudscheduler_region}",
},
"environment": {
"numWorkers": "2",
"tempLocation": "gs://gcslocation/temp2",
"zone": "${var.cloudscheduler_region}-a"
}
}
EOT
)
}

How to pass the scheduled date/rundate in the body "runningdate" :???????? of cloudscheduler which we read in dataflow job code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

财迷小姐 2025-01-23 06:24:31

(简单方法)尝试使用 Cloud Functions 而不是 云调度程序

Cloud Scheduler 应该像 unix cron 作业一样工作,来安排和运行作业。

云函数主要适用于需要解析和解析参数的用例。做出动态决策,例如我是否应该运行数据流作业或任何此类作业。

如果您有使用Cloud Scheduler的需求/此类用例,那么您可以做的是

  • 使用Cloud Functions记录您的参数并存储在常见的可访问位置,例如数据库或存储桶
  • 之后使用Cloud Scheduler执行所需的步骤。

如果我误解了您的问题,请详细说明更多细节和信息。例子。

(Simple Approach) Try using Cloud Functions rather than Cloud Scheduler.

Cloud Scheduler is supposed work like a unix cron job, to schedule and run jobs.

Cloud Functions are mainly useful for uses cases where arguments need to be parsed & dynamic decision to be made like should I run Dataflow job or any as such.

If you have requirement/such use case to use Cloud Scheduler, then what you can do is

  • Use Cloud Functions to record your arguments and store in commonly accessible locations like DB or Bucket
  • Use Cloud Scheduler to do the required step after that.

If I misunderstood, your question, please do elaborate with more details & examples.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文