Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scality/zookeeper-mock
NodeJS Zookeeper Mock
https://github.com/scality/zookeeper-mock
artesca ring
Last synced: 2 months ago
JSON representation
NodeJS Zookeeper Mock
- Host: GitHub
- URL: https://github.com/scality/zookeeper-mock
- Owner: scality
- License: apache-2.0
- Created: 2019-06-25T00:47:33.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T23:39:54.000Z (over 1 year ago)
- Last Synced: 2024-10-13T22:19:24.752Z (3 months ago)
- Topics: artesca, ring
- Language: JavaScript
- Homepage:
- Size: 306 KB
- Stars: 3
- Watchers: 45
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zookeeper-mock
[![CircleCI](https://circleci.com/gh/scality/zookeeper-mock.svg?style=svg)](https://circleci.com/gh/scality/zookeeper-mock)This module can be used as a Zookeeper mock to simulate race
conditions in programs.Examples of use:
```
const zkc = new ZookeeperMock();
const subPath = '/workflow-engine';
const path1 = `${subPath}/xxx`;
const path2 = `${subPath}/xxx`;
const path3 = `${subPath}/xxx`;
const data1 = 42;
const data2 = 43;
const data3 = 44;
zkc.mkdirp(path1, data1, {},
zookeeper.CreateMode.PERSISTENT_SEQUENTIAL,
err => {
assert.ifError(err);
// simulate a race
process.nextTick(() => {
zkc.mkdirp(path2, data2, {},
zookeeper.CreateMode.PERSISTENT_SEQUENTIAL,
(err, path) => {
assert.ifError(err);
if (path === `${path1}0000000002`) {
// th1 firing
return done();
}
return undefined;
});
});
process.nextTick(() => {
zkc.mkdirp(path3, data3, {},
zookeeper.CreateMode.PERSISTENT_SEQUENTIAL,
(err, path) => {
assert.ifError(err);
if (path === `${path1}0000000002`) {
// th2 firing
return done();
}
return undefined;
});
});
});
});
```