On Thu, Sep 19, 2013 at 11:23 AM, Ivan Maximenko
<ivanmaxime...@gmail.com> wrote:
> Hello, I'm newest in nodejs.
> My application based on expressjs + cluster.
>
> And now for me is not clear how to share data between processes?
> Code example :
>
> function Acl(storage) { //storage - mongodb
>    return {
>        isAllow: function(role, resource, cb) {
>            if (!cache) {
>                 loadCache(function() {
>                     //check permissions
>                 });
>            }
>        },
>        allow: function(role, resource, permissions, cb) {
>            storage.save({
>                  role: role,
>                  resource: resource,
>                  permissions: permissions
>            }, function() {
>                //put to cache
>                //inform of all processes that acl was changed
>                cb(null, true);
>            });
>        }
>    }
> }
>
> Thanks for help!

The cluster API lets you pass messages from the master to the worker
and vice versa (but not from worker to worker - if you want that, you
need to set up the master to function as a broker.)

The functions you want are worker.send() (in the master) and
process.send() in the worker.  Received messages are emitted as
'message' events on the worker and process objects respectively.  The
cluster documentation has more information.  Good luck!

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to