在运行时在node.js中启用和声代理 [英] Enable harmony proxies at runtime in node.js
问题描述
我有一个用于节点的RPC库,现在它对远程对象(如果可用)(通过检查是否存在Proxy
全局对象)使用协调代理.
I have a little RPC library for node, and right now it uses harmony proxies for remote objects if they are available (by checking for the existence of a Proxy
global).
我希望能够在运行时(即,不是以--harmony-proxy
标志开始的节点进程中)打开和声代理.这可能吗?
I'd like to be able to turn harmony proxies on at runtime, that is, in a node process that was not started with the --harmony-proxy
flag. Is this possible?
我知道有充分的理由不这样做,而且我也不在乎:-P
I understand that there are good reasons not to do this, and I don't really care :-P
编辑如答案中所指出,node.js代理使用的是较旧的规范.我可以使用 https://github.com/tvcutsem/harmony-reflect 之类的垫片工作可以解决这个问题,但这仍然需要--harmony
标志来启用基础代理支持,我想知道是否有可能在运行时在没有--harmony
标志的情况下启用该功能.
EDIT As pointed out in the answers, node.js proxies use an older spec. I can use a shim like https://github.com/tvcutsem/harmony-reflect to work around this, but this still requires the --harmony
flag to enable the underlying proxy support, and I want to know whether it's possible to enable that at runtime in a process started without the --harmony
flags.
推荐答案
代理的版本取决于您使用的是master
还是v0.10
.最新的稳定版(v0.10
)使用3.14
分支,而开发版(master
)保留在v8 bleeding_edge
(当前为3.20
)上.因此,更正确的问题是"v8实施了什么版本的代理?"
The version of Proxy is depend on whether you use master
or v0.10
. Latest stable (v0.10
) uses the 3.14
branch, while development (master
) stays with v8 bleeding_edge
(currently at 3.20
). So the more correct question is, "what version of proxies has v8 implemented?"
有关代理实现的工作正在完成,但是现在这是一个移动的目标.在错误跟踪器( http://code.google .com/p/v8/issues/detail?id = 1543 ),似乎又要进行另一轮更改了.因此,请注意即将进行的开发.
Work is being done on the proxy implementation, but it's a moving target right now. Referencing the proxy implementation ticket in the bug tracker (http://code.google.com/p/v8/issues/detail?id=1543) it looks like another round of changes are coming. So be careful with upcoming development.
至于在应用程序而不是命令行中启用代理,我相信您必须编写一个本机模块并使用V8::SetFlagsFromString
方法(
As far as enabling proxies in the app and not the command line I believe you'll have to write a native module and use the V8::SetFlagsFromString
method (https://github.com/v8/v8/blob/f281162/include/v8.h#L4341-L4344). If you need an example I might make time to whip one up.
这篇关于在运行时在node.js中启用和声代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!