如何配置EventBridge计划规则以动态触发我的Lambda函数?

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

How to configure EventBridge Scheduled Rule to trigger my Lambda function dynamically?

问题

我需要关于一个主题的帮助。(我正在使用AWS)

我正在尝试在我的应用程序中使用iOS的实时活动。我意识到在用户手机上关闭应用程序时,我必须在服务器端更新实时活动变量。 --> 文档

我需要在用户采取行动后的4小时内更新用户的实时活动中的一些变量。我的意思是这种情况:

  • 用户在应用程序上执行一个操作并调用一个端点。
  • 4小时后,实时活动中的某些变量应该更改。

我创建了这个解决方案:

  • 当用户调用API时,我可以在EventBridge上创建一个计划事件。此事件在4小时后触发Lambda函数。
  • Lambda函数将更新实时活动。

但我无法动态地安排EventBridge的计划事件。当我尝试在默认事件总线上创建规则时,我可以选择计划规则类型。但我只能使用cron表达式设置特定的时间。

事件没有安排功能。规则具有该功能。因此,我尝试创建规则并将事件发送到我的API上的规则。但我无法在代码中设置目标(Lambda函数)。

我认为我可能遗漏了一些东西并且迷失了方向。

你有关于解决这个问题的任何想法吗?

非常感谢

英文:

I need help about a subject. (I'm using AWS)

I'm trying to use live activity of ios in my application. I realize that I have to update live activity variable on server side while application is closed on user phone. --> docs

I need that update some variables on live activity of user after than 4 hours of user action. I mean that scenario:

  • User make an action on app and an endpoint called.
  • After 4 hours, some variable should change on live activity.

I create this solution:

  • When user call api, I can create an scheduled event on EventBridge. This event trigger lambda function after 4 hours.
  • Lambda function will update live activity

But I can not scheduled event of EventBridge dynamically. While I try to create rule on default eventbus, I can choose Scheduled rule type. But I can set only specific time with cron expression.

Events have not schedule feature. Rules have that feature. So I tried create rule and send event to rule on my api. But I can not set target (lambda func) on code.

I think that I'm missing something and lost way.

Do you have any idea about solve this issue?

Thanks a lot

答案1

得分: 0

I solved this issue.
EventBridge 不适合我的需求,我使用了 EventBridge-Scheduler(工具的新/最后一部分)
你可以在这里找到差异(aws文档):
如何配置EventBridge计划规则以动态触发我的Lambda函数?

调度程序部分有一次性调度选项,事件触发后删除选项,时间窗口调度以及指定的精确日期和时间。
调度程序更适合我的需求。

英文:

If my description is bad, I'm sorry for this..

I solved this issue.

EventBridge is not suit for my needs, I used EventBridge-Scheduler (new/last part of tool)

You can find differences here (aws document):
如何配置EventBridge计划规则以动态触发我的Lambda函数?

Scheduler part has one-time schedule option, deleted after event trigger option,'time window schedules' and specified for exact date time.

The Scheduler is more suit for my needs.

huangapple
  • 本文由 发表于 2023年8月11日 02:22:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76878396.html
匿名

发表评论

匿名网友

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

确定