简体   繁体   English

在运行时在node.js中启用和声代理

[英]Enable harmony proxies at runtime in node.js

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). 我有一个用于节点的RPC库,现在它对远程对象使用和谐代理( 如果它们可用) (通过检查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. 我希望能够在运行时打开和谐代理,即,在不是以--harmony-proxy标志启动的节点进程中。 Is this possible? 这可能吗?

I understand that there are good reasons not to do this, and I don't really care :-P 我知道有充分的理由这样做,而且我也不在乎:-P

EDIT As pointed out in the answers, node.js proxies use an older spec. 编辑正如答案中指出的那样,node.js代理使用较旧的规范。 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. 我可以使用类似https://github.com/tvcutsem/harmony-reflect的填充程序来解决此问题,但这仍然需要--harmony标志来启用基础代理支持,我想知道是否有可能启用在运行时启动的进程中没有--harmony标志。

The version of Proxy is depend on whether you use master or v0.10 . Proxy的版本取决于您使用master还是v0.10 Latest stable ( v0.10 ) uses the 3.14 branch, while development ( master ) stays with v8 bleeding_edge (currently at 3.20 ). 最新的稳定版( v0.10 )使用3.14分支,而开发( master )则停留在v8 bleeding_edge v0.10 (当前为3.20 )处。 So the more correct question is, "what version of proxies has v8 implemented?" 因此,更正确的问题是“ v8实现了什么版本的代理?”

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. 引用错误跟踪器( http://code.google.com/p/v8/issues/detail?id=1543 )中的代理实施票证,似乎即将进行另一轮更改。 So be careful with upcoming development. 因此,请注意即将进行的开发。

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 ). 至于在应用程序而不是命令行中启用代理,我相信您必须编写一个本机模块并使用V8::SetFlagsFromString方法( 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 implements an older proxy specification. Node.js实现了较旧的代理规范。 Don't use them. 不要使用它们。

https://groups.google.com/forum/?fromgroups=#!topic/nodejs/LPD8ut33-hg https://groups.google.com/forum/?fromgroups=#!topic/nodejs/LPD8ut33-hg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM