跳转到内容
View in the app

A better way to browse. Learn more.

彼岸论坛

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
欢迎抵达彼岸 彼岸花开 此处谁在 -彼岸论坛

[程序员] 使用 temporal 构建工作流时,对于长时间任务是在 workflow 里轮询好还是 activity 里轮询好?

发表于

rt ,现在有一个文本下发的任务,选中设备,设置执行时间。设备上线后,给设备下发文本指令。在工作流中,需要 在 for 循环中遍历设备列表,对在线的设备下发指令,记录结果,直到所有设备下发完成,任务结束。执行时间可能是几天甚至一两周。

刚开始学习使用 temporal ,现在想到有两种方案:

  1. 在 workflow 中使用 for 循环执行 activity ,每次 activity 返回是否完成的标签,然后使用 workflow.sleep 设置间隔时间,直到返回 true 则任务执行完成。

  2. 直接在 activity 中使用 for select 循环执行直到所有设备完成结束 activity ,任务完成。

现要求任务可以取消、可持久化、worker 断开重启后可以继续执行。请问下我这种长时间任务正确的做法是该使用哪种模式?

Featured Replies

No posts to show

创建帐户或登录来提出意见

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.