Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.

Commit b43e233

Browse files
committed
Move from substack to Level
- Update & rename README.md - Update repository URLs - Add CONTRIBUTORS.md - Add hallmark & level-community - Add code coverage with nyc & coveralls - Add dependency-check - Add engines.node to package.json - Add standard
1 parent 84946a3 commit b43e233

File tree

8 files changed

+205
-149
lines changed

8 files changed

+205
-149
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
coverage
3+
.nyc_output
4+
example/data

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
language: node_js
2+
23
node_js:
34
- 8
45
- 10
56
- 12
7+
8+
before_script: git fetch --tags
9+
after_success: npm run coverage
10+
11+
notifications:
12+
email: false

CONTRIBUTORS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Contributors
2+
3+
| Name | GitHub | Social |
4+
| :------------------ | :--------------------------------------------- | :------------------------------------------------------ |
5+
| **James Halliday** | [**@substack**](https://github.com/substack) | [**@substack@twitter**](https://twitter.com/substack) |
6+
| **Mathias Buus** | [**@mafintosh**](https://github.com/mafintosh) | [**@mafintosh@twitter**](https://twitter.com/mafintosh) |
7+
| **Vincent Weevers** | [**@vweevers**](https://github.com/vweevers) | [**@vweevers@twitter**](https://twitter.com/vweevers) |

LICENSE

Lines changed: 0 additions & 18 deletions
This file was deleted.

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The MIT License (MIT)
2+
3+
**Copyright © 2014-present James Halliday and [Contributors](CONTRIBUTORS.md).**
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# level-party
2+
3+
Open a leveldb handle multiple times, transparently upgrading to use
4+
[`multileveldown`](https://npmjs.org/package/multileveldown) when more than 1 process try to use the same leveldb data directory at once and re-electing a new master when the primary unix socket goes down.
5+
6+
[![level badge][level-badge]](https://github.com/Level/awesome)
7+
[![npm](https://img.shields.io/npm/v/level-party.svg?label=&logo=npm)](https://www.npmjs.com/package/level-party)
8+
[![Node version](https://img.shields.io/node/v/level-party.svg)](https://www.npmjs.com/package/level-party)
9+
[![Travis](https://img.shields.io/travis/com/Level/party.svg?logo=travis&label=)](https://travis-ci.com/Level/party)
10+
[![Coverage Status](https://coveralls.io/repos/github/Level/party/badge.svg)](https://coveralls.io/github/Level/party)
11+
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
12+
[![npm](https://img.shields.io/npm/dm/level-party.svg?label=dl)](https://www.npmjs.com/package/level-party)
13+
[![Backers on Open Collective](https://opencollective.com/level/backers/badge.svg?color=orange)](#backers)
14+
[![Sponsors on Open Collective](https://opencollective.com/level/sponsors/badge.svg?color=orange)](#sponsors)
15+
16+
## Example
17+
18+
Normally with [`level`](https://npmjs.org/package/level), when you try to open
19+
a database handle from more than one process you will get a locking error:
20+
21+
```
22+
events.js:72
23+
throw er; // Unhandled 'error' event
24+
^
25+
OpenError: IO error: lock /home/substack/projects/level-party/example/data/LOCK: Resource temporarily unavailable
26+
at /home/substack/projects/level-party/node_modules/level/node_modules/level-packager/node_modules/levelup/lib/levelup.js:114:34
27+
```
28+
29+
With `level-party`, the database open will automatically drop down to using
30+
multilevel over a unix socket using metadata placed into the level data
31+
directory transparently.
32+
33+
This means that if you have 2 programs, 1 that gets:
34+
35+
```js
36+
var level = require('level-party');
37+
var db = level(__dirname + '/data', { valueEncoding: 'json' });
38+
39+
setInterval(function () {
40+
db.get('a', function (err, value) {
41+
console.log('a=', value);
42+
});
43+
}, 250);
44+
```
45+
46+
And 1 that puts:
47+
48+
```js
49+
var level = require('level-party');
50+
var db = level(__dirname + '/data', { valueEncoding: 'json' });
51+
52+
var n = Math.floor(Math.random() * 100000);
53+
54+
setInterval(function () {
55+
db.put('a', n + 1);
56+
}, 1000);
57+
```
58+
59+
and you start them up in any order, everything will just work! No more
60+
`IO error: lock` exceptions.
61+
62+
```
63+
$ node put.js & sleep 0.2; node put.js & sleep 0.2; node put.js & sleep 0.2; node put.js & sleep 0.2
64+
[1] 3498
65+
[2] 3502
66+
[3] 3509
67+
[4] 3513
68+
$ node get.js
69+
a= 35340
70+
a= 31575
71+
a= 37639
72+
a= 58874
73+
a= 35341
74+
a= 31576
75+
$ node get.js
76+
a= 35344
77+
a= 31579
78+
a= 37643
79+
a= 58878
80+
a= 35345
81+
^C
82+
```
83+
84+
Hooray!
85+
86+
## Seamless failover
87+
88+
level-party does seamless failover. This means that if you create a read-stream
89+
and the leader goes down while you are reading that stream level-party will resume your stream on the new leader.
90+
91+
[**This disables leveldb snapshotting**](https://github.com/level/leveldown#snapshots) so if your app relies on this you should disable this by setting `opts.retry = false`
92+
93+
```js
94+
var db = level('./data', {retry: false}) // will not retry streams / gets / puts if the leader goes down
95+
```
96+
97+
## Windows support
98+
99+
`level-party` works on windows as well using named pipes.
100+
101+
## API
102+
103+
### `var db = level(...)`
104+
105+
The arguments are exactly the same as [`level`](https://npmjs.org/package/level). You will sometimes get a real leveldb handle and sometimes get a `multileveldown` handle back in the response.
106+
107+
## Install
108+
109+
With [npm](https://npmjs.org) do:
110+
111+
```
112+
npm install level-party
113+
```
114+
115+
## Contributing
116+
117+
[`Level/party`](https://github.com/Level/party) is an **OPEN Open Source Project**. This means that:
118+
119+
> Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
120+
121+
See the [Contribution Guide](https://github.com/Level/community/blob/master/CONTRIBUTING.md) for more details.
122+
123+
## Donate
124+
125+
To sustain [`Level`](https://github.com/Level) and its activities, become a backer or sponsor on [Open Collective](https://opencollective.com/level). Your logo or avatar will be displayed on our 28+ [GitHub repositories](https://github.com/Level) and [npm](https://www.npmjs.com/) packages. 💖
126+
127+
### Backers
128+
129+
[![Open Collective backers](https://opencollective.com/level/backers.svg?width=890)](https://opencollective.com/level)
130+
131+
### Sponsors
132+
133+
[![Open Collective sponsors](https://opencollective.com/level/sponsors.svg?width=890)](https://opencollective.com/level)
134+
135+
## License
136+
137+
[MIT](LICENSE.md) © 2014-present James Halliday and [Contributors](CONTRIBUTORS.md).
138+
139+
[level-badge]: https://leveljs.org/img/badge.svg

package.json

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
{
22
"name": "level-party",
33
"version": "3.0.4",
4-
"description": "open a leveldb handle multiple times",
4+
"description": "Open a leveldb handle multiple times",
5+
"license": "MIT",
56
"main": "index.js",
7+
"author": {
8+
"name": "James Halliday",
9+
"email": "[email protected]",
10+
"url": "http://substack.net"
11+
},
12+
"scripts": {
13+
"test": "standard && hallmark && nyc tape test/*.js",
14+
"coverage": "nyc report --reporter=text-lcov | coveralls",
15+
"hallmark": "hallmark --fix",
16+
"dependency-check": "dependency-check --no-dev . test/*.js",
17+
"prepublishOnly": "npm run dependency-check"
18+
},
619
"dependencies": {
720
"has": "^1.0.0",
821
"level": "^6.0.0",
@@ -11,18 +24,24 @@
1124
},
1225
"devDependencies": {
1326
"bytewise": "^1.1.0",
27+
"coveralls": "^3.0.9",
28+
"dependency-check": "^4.1.0",
29+
"hallmark": "^2.0.0",
30+
"level-community": "^3.0.0",
31+
"nyc": "^14.1.1",
1432
"osenv": "~0.1.0",
33+
"standard": "^14.3.1",
1534
"subleveldown": "^4.1.4",
1635
"tape": "^4.11.0"
1736
},
18-
"scripts": {
19-
"test": "tape test/*.js"
37+
"hallmark": {
38+
"community": "level-community"
2039
},
2140
"repository": {
2241
"type": "git",
23-
"url": "git://github.com/substack/level-party.git"
42+
"url": "https://github.com/Level/party.git"
2443
},
25-
"homepage": "https://github.com/substack/level-party",
44+
"homepage": "https://github.com/Level/party",
2645
"keywords": [
2746
"level",
2847
"leveldb",
@@ -33,10 +52,7 @@
3352
"unix",
3453
"socket"
3554
],
36-
"author": {
37-
"name": "James Halliday",
38-
"email": "[email protected]",
39-
"url": "http://substack.net"
40-
},
41-
"license": "MIT"
55+
"engines": {
56+
"node": ">=8"
57+
}
4258
}

readme.markdown

Lines changed: 0 additions & 120 deletions
This file was deleted.

0 commit comments

Comments
 (0)