将基于 python-twisted 的代码移植到 scala:需要框架建议
我正在尝试将大量用 python 编写的代码移植到 scala,并且我正在寻找关于选择哪种框架组合的意见。
它本质上是一个 RPC(基于自定义 protobuf + xmlrpc)/HTTP 服务器和客户端,它执行一些数据库保存和转换,但稍后将 RPC 发送给超出此重写范围的工作人员。
作为实现 RPC 堆栈的网络 IO/基础,我使用 netty。旧的东西中的所有工作流程都是基于twisted的Deferred,为了替换它,我目前正在考虑直接使用ChannelFuture,或者将其包装在scalaz.Promise或akka.Future中。
我想,问题的一部分是 - 它可以比手动使用回调更简单吗?我想,如果我选择这条路线,我可以稍后通过添加一些包装器和使用延续来简化它,但也许我需要使用与开始不同的东西?
我尝试将工作流程放入参与者模型中,但它似乎不适用于 stdlib 参与者。
谢谢。
更新: Finagle 的模型似乎与 Twisted 非常接近,或者至少意外地相似。 twitter.util.Future 看起来很像twisted 的Deferred。所以我暂时使用它。
更新 2: 我首先移植它的原因是静态类型和性能。
I am trying to port a significant amount of code written in python with twisted to scala, and I'm looking for opinions on what framework combination to choose.
The thing is essentially an RPC (custom protobuf-based + xmlrpc)/HTTP server and client, that does some database-keeping and transformations but later sends down rpcs to workers which are outside of the scope of this rewrite.
As a network IO/base for implementing RPC stack I am using netty. All the workflows in the old thingy were based on twisted's Deferred, and to replace it I'm currently considering either ChannelFuture directly, or wrapping it inside either scalaz.Promise or akka.Future.
I guess, one part of the question is - can it be done simpler than manually working with callbacks? I guess, if I choose this route, I can simplify it later by adding some wrappers and using continuations, but maybe I need to use something different from the beginning?
I tried to fit the workflow inside actor model but it doesn't seem to work with stdlib actors.
Thanks.
Update: Finagle seems to be modeled closely after, or at least accidentally similar, to twisted. twitter.util.Future looks a lot like twisted's Deferred. So I'm using it for the moment.
Update 2: The reasons why I ported it in the first place are static typing and performance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Finagle 似乎与 Twisted 非常相似,或者至少意外地相似。 twitter.util.Future 看起来很像twisted 的Deferred。所以我暂时使用它。
Finagle seems to be modeled closely after, or at least accidentally similar, to twisted. twitter.util.Future looks a lot like twisted's Deferred. So I'm using it for the moment.