🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

abstract-skiff-persistence

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-skiff-persistence

Abstract Skiff Persistence provider

0.8.0
latest
Source
npm
Version published
Weekly downloads
14
250%
Maintainers
1
Weekly downloads
 
Created
Source

Abstract Skiff Persistence

Abstract prototype for building a Skiff persistence provider.

Install

$ npm install abstract-skiff-persistence

## Implement

```javascript
var AbstractSkiffPersistence = require('abstract-skiff-persistence');
var inherits = require('util').inherits;

module.exports = FakeSkiffPersistence;

function FakeSkiffPersistence() {
}

inherits(FakeSkiffPersistence, AbstractSkiffPersistence);

FakeSkiffPersistence.prototype._
'use strict';

module.exports = AbstractSkiffPersistence;

function AbstractSkiffPersistence(options) {
}

FakeSkiffPersistence.prototype._saveMeta = function(nodeId, state, callback) {
  // ...
};

FakeSkiffPersistence.prototype._loadMeta = function(nodeId, callback) {
  // ...
};

FakeSkiffPersistence.prototype._applyCommand = function(nodeId, commitIndex, command, callback) {
  // ...
};

FakeSkiffPersistence.prototype._lastAppliedCommitIndex = function(nodeId, callback) {
  // ...
};

FakeSkiffPersistence.prototype._saveCommitIndex = function(nodeId, commitIndex, callback) {
  // ...
};

FakeSkiffPersistence.prototype._createReadStream = function(nodeId) {
  // ...
};

FakeSkiffPersistence.prototype._createWriteStream = function(nodeId) {
  // ...
};

FakeSkiffPersistence.prototype._removeAllState = function(nodeId, callback) {
  // ...
};

FakeSkiffPersistence.prototype._close = function(callback) {
  // ...
};

Test

You can use this module to test your Skiff Persistence provider:

'use strict';

var test = require('abstract-skiff-persistence/test/all');

var FakeSkiffPersistence = require('../');
var p = new FakeSkiffPersistence();

var options = {
  commands: [
    {type: 'put', key: 'a', value: 1},
    {type: 'put', key: 'b', value: 2},
    {type: 'del', key: 'a'},
    {type: 'put', key: 'c', value: {some: 'object'}}
  ],
  expectedReads: [
    {key: 'b': value: 2},
    {key: 'c': value: {some: 'object'}}
  },
  newWrites: [
    {type: 'put', key: 'd', value: 3},
    {type: 'put', key: 'e', value: {some: 'other object'}},
    {type: 'put', key: 'f', value: 'some other string'}
  ],
  newReads: [
    {key: 'd', value: 3},
    {key: 'e', value: {some: 'other object'}},
    {key: 'f', value: 'some other string'}
  ]
};

test(p, options);

License

ISC

FAQs

Package last updated on 28 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts