Skip to content

An opinionated isomorphic wrapper around levelup for cluster compatibility

License

Notifications You must be signed in to change notification settings

chiguireitor/cluster-levelup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cluster-levelup

An opinionated isomorphic wrapper around levelup for cluster compatibility.

Doesn't includes backend, you can use leveldown, memdown or your own.

Master is always considered the database "opener", workers communicate with the database via RPC calls.

More goodness

You can find more useful stuff for levelup on awesome.

Example

Just use as if you were using levelup on the workers.

const levelup = require('cluster-levelup')
const cluster = require('cluster')

if (cluster.isMaster) {
  levelup(require('memdown')(), {}, (err, db) => {
    if (err) {
      throw err
    } else {
      db.put('test', 'value', (err) => {
        if (err) {
          throw err
        } else {
          console.log('Forking')
          cluster.fork()
        }
      })
    }
  })
} else {
  levelup.get('test', (err, data) => {
    if (err) {
      throw err
    } else {
      console.log('test', '=', data)
    }
  })
}

License

Copyright 2018 John "Chiguireitor" Villar

cluster-levelup is licensed under the ISC license. All rights not explicitly granted in the ISC license are reserved. See the included LICENSE.md file for more details.

About

An opinionated isomorphic wrapper around levelup for cluster compatibility

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published