|
|
@ -19,8 +19,8 @@ you're trying to use (for example express-session/session/memory, sqlite3, level |
|
|
|
and then you will supply the names of the methods you wish to export to **worker** |
|
|
|
processes. |
|
|
|
|
|
|
|
You must pass each worker via `addWorker()` so that it signals the worker to creates |
|
|
|
its own rpc-wrapped instance. |
|
|
|
By default each worker will be added when `cluster` emits a `fork` event. |
|
|
|
If needed you can set `addOnFork` to `false` and call `addWorker(worker)` manually. |
|
|
|
|
|
|
|
### master |
|
|
|
|
|
|
@ -32,14 +32,15 @@ var db = require('level')('./mydb') |
|
|
|
|
|
|
|
// Wrap the instance |
|
|
|
var crpc = require('cluster-rpc/master').create({ |
|
|
|
instance: db |
|
|
|
addOnFork: true // default |
|
|
|
, instance: db |
|
|
|
, methods: [ 'get', 'put' ] |
|
|
|
, name: 'foo-level' |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// You must add each worker |
|
|
|
crpc.addWorker(cluster.fork()); |
|
|
|
// If you set addOnFork to false, You must manually add each worker |
|
|
|
// crpc.addWorker(cluster.fork()); |
|
|
|
|
|
|
|
|
|
|
|
crpc.then(function (db) { |
|
|
@ -77,7 +78,8 @@ if (cluster.isMaster) { |
|
|
|
|
|
|
|
|
|
|
|
crpc = require('cluster-rpc/master').create({ |
|
|
|
instance: require('level')('./mydb') |
|
|
|
addOnFork: false |
|
|
|
, instance: require('level')('./mydb') |
|
|
|
, methods: [ 'get', 'put' ] |
|
|
|
, name: 'foo-level' |
|
|
|
}); |
|
|
|