当异步过程完成时,UI设计模式 /技术用于监视

发布于 2025-01-22 08:46:16 字数 154 浏览 3 评论 0原文

我的前端通过HTTP帖子开始了异步过程。

无论如何(KAFKA,螺纹,数据库插入和另一个监视表的系统),以某种量化的方式完成了一些过程和完成后完成(您可以进行HTTP调用,并确定其是否完成)) 。

是否有任何设计模式/技术可以通知前端,而无需对某些服务提出重复请求?

My frontend kicks off an async process with an http POST.

By whatever means, (kafka, threading, database insert and another system monitoring the table), some process is completed after an unknown amount of time and finishes in some quantifiable way (you can make a http call and determine if its done or not).

Are there any design patterns/technologies for notifying the frontend without it having to make repeated requests to some service?

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

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

发布评论

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

评论(1

清醇 2025-01-29 08:46:16

您可以看一下 WebSockets ,一种通常用于实时Web应用程序的双向数据频道。

您可以使用的方式将是直接的:当您提出HTTP POST请求并在后端启动异步过程时,您还为该特定的请求打开了使用前端的Websocket连接。当异步过程完成后,后端将通过Websocket通知前端。

您甚至可以使用相同的Websocket连接将数据传输到多个请求(由同一用户启动),这是一种多路复用技术。

如果您需要可扩展的整体系统,则应考虑拥有一个管理WebSocket连接的VM群(与应用程序的后端完全分开)。

You can take a look on WebSockets, a bi-directional data channel that is generally used for real-time web applications.

The way you can use would be straight-forward: when you make the HTTP Post request and the async process is started on the backend, you also open a websocket connection with the front-end, for that particular request. When the async process is finished, the backend will notify the front-end through the websocket.

You can even use the same websocket connection to transport data for multiple requests (initiated by the same user), which is a kind of a multiplexing technique.

If you need the overall system to be scalable, you should think about having a cluster of VMs that manage the websocket connections (fully separated from the backend of your application).

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