Skip to content

Support marshalling closures for distributed computing #2938

Closed
@dodtsair

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions