Sitelet https://github.com/nodejs/node/issues/2938
Skip to content

Support marshalling closures for distributed computing #2938

Description

@dodtsair

nodejs should support marshalling closures between two different node instances. You can imagine this being used by a jobs library.

var from = "user@nodejs.org";
var to = "featurerequest@nodejs.org"
...
job.post(function() {
    emailService.send(from, to, {subject: "Feature request - marshal closures", body: "Nodejs should support marshalling closures for distributed computing"});
});

In this example to and from should be marshalled with the closure. The result could be read into another nodejs instance and executed to send an email. This technique is used extensively with jenkins to send work from the master instance to the slave instance.

As demonstrated by the sample code there is a technical question. How would you handle emailService? Does it get marshalled? How do you refer to a component that is on the target and not on the source? Would there be a need to mark things so that they are not marshalled?

For example the code could be changed to:

var from = "user@nodejs.org";
var to = "featurerequest@nodejs.org"
...
job.post(function() {
    require(emailService).send(from, to, {subject: "Feature request - marshal closures", body: "Nodejs should support marshalling closures for distributed computing"});
});

Would the require function not get marshalled, would the result of the require call return the target's email service?

Activity

  1. vkurchatkin commented on Sep 17, 2015

    @vkurchatkin
    Contributor

    What you propose seems very hard to implement (if not impossible) and not worth it. You can achieve the same result by having a global registry of jobs and passing parameters as json.

  2. bnoordhuis commented on Sep 17, 2015

    @bnoordhuis
    Member

    This would have to be implemented in V8 first and they're unlikely to entertain such feature requests. Closing, not actionable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues asking questions about Node.js.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions