domain.enter()
enter() 方法是由 run()、bind() 和 intercept() 方法使用的底层机制,用于设置活动域。它将 domain.active 和 process.domain 设置为该域,并隐式地将该域推入由 domain 模块管理的域栈(有关域栈的详细信息,请参见 domain.exit())。调用 enter() 标志着与域绑定的一链异步调用和 I/O 操作的开始。
【The enter() method is plumbing used by the run(), bind(), and
intercept() methods to set the active domain. It sets domain.active and
process.domain to the domain, and implicitly pushes the domain onto the domain
stack managed by the domain module (see domain.exit() for details on the
domain stack). The call to enter() delimits the beginning of a chain of
asynchronous calls and I/O operations bound to a domain.】
调用 enter() 只会改变活动域,并不会修改域本身。enter() 和 exit() 可以在同一个域上任意次调用。
【Calling enter() changes only the active domain, and does not alter the domain
itself. enter() and exit() can be called an arbitrary number of times on a
single domain.】