在浏览器和服务器之间共享逻辑

发布于 2024-08-08 10:06:51 字数 765 浏览 3 评论 0原文

我正在开发一个应用程序,它像大多数应用程序一样,具有大量的业务逻辑,几乎所有这些逻辑都需要在服务器和基于 Flash 的客户端上执行......我正在尝试计算找出实现规则引擎的最佳(阅读:最简单)方法。

这些是问题的参数:

  1. 规则引擎必须同时在 Web 浏览器(即在 Flash Player 中)和服务器上运行。重复逻辑(例如,通过编写“服务器”版本和“客户端”版本)将是不可接受的风险。
  2. 输入/输出数据相当复杂,因此序列化是一个不平凡的问题。我们目前正在使用 AMF 来满足所有序列化需求,而使用其他协议会显着增加复杂性……因此应该避免使用它。
  3. 实现“规则描述语言”是不可行的。实验表明,规则足够复杂,任何此类语言都需要图灵完备……这也会显着增加复杂性。
  4. 规则引擎不需要进行一些但不是很多的服务调用。

目前,最好的竞争者是:

  1. 用 ActionScript 编写代码,然后在服务器上运行它。理论上,可以启动一个 AVM 实例,让它长轮询网关,然后以这种方式来回传递数据……但这似乎不太理想。有没有一种“好的”方法可以做到这一点?

  2. 用 Haxe 编写代码。我对 Haxe 的 AMF 支持一无所知,因此这可能会破坏交易。

  3. 涉及狨猴的东西。似乎是一个可行的选择,但我还没有做足够的研究来判断这两种方式。

那么,你觉得怎么样?这些选项中的任何一个明显比其他选项更好吗?有什么我没有想到的值得考虑的事情吗?

最后,感谢您阅读这面文字墙:)

I'm working on an app which will, like most apps, have a whole boat load of buisness logic, almost all of which will need to be executed both on the server and the Flash-based client… And I'm trying to figure out the best (read: least complex) way to implement the rules engine.

These are the parameters of the problem:

  1. The rules engine must both run in a web browser (ie, in Flash Player) and on the server. Duplicating the logic (eg, by writing a "server" version and a "client" version) would be an unacceptable risk.
  2. The input/output data is fairly complex, so serialization is a nontrivial problem. We are currently using AMF for all of our serialization needs, and using another protocol would add significant complexity… So it should probably be avoided.
  3. It is infeasible to implement a "rules description language". Experimentation has shown that rules are sufficiently complex that any such language would need to be Turing complete… Which would also add a significant amount of complexity.
  4. The rules engine will not need to make some, but not very many, service calls.

Currently, the best contenders are:

  1. Writing the code in ActionScript, then running it on the server. In theory it's possible to start up an AVM instance, get it long-polling a gateway, then pass data back and forth that way… But that seems less than ideal. Is there a "good" way of doing this?

  2. Writing the code in Haxe. I don't know anything about Haxe's AMF support, so that could be a deal-breaker.

  3. Something involving Tamarin. Seems like a viable option, but I haven't done enough research to tell either way.

So, what do you think? Are any of these options clearly better than others? Is there something I haven't though of that's worth considering?

Finally, thanks for reading this wall of text :)

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

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

发布评论

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

评论(1

柏林苍穹下 2024-08-15 10:06:51

你说的是多少数据?如果你想在服务器上运行 Air 并访问队列或其他东西,你可以使用 Air。

How much data are you talking about? You can use Air if you want to run it on the server and access a queue or something.

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