@keyv/etcd 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/package.json +28 -11
- package/src/index.d.ts +19 -8
- package/src/index.js +8 -4
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# @keyv/
|
|
1
|
+
# @keyv/etcd [<img width="100" align="right" src="https://jaredwray.com/images/keyv.svg" alt="keyv">](https://github.com/jaredwra/keyv)
|
|
2
2
|
|
|
3
3
|
> Etcd storage adapter for Keyv
|
|
4
4
|
|
|
5
5
|
[](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml)
|
|
6
|
-
[](https://codecov.io/gh/jaredwray/keyv)
|
|
7
7
|
[](https://www.npmjs.com/package/@keyv/etcd)
|
|
8
8
|
|
|
9
9
|
Etcd storage adapter for [Keyv](https://github.com/jaredwray/keyv).
|
|
@@ -25,4 +25,4 @@ keyv.on('error', handleConnectionError);
|
|
|
25
25
|
|
|
26
26
|
## License
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
Copyright (c) 2022 Jared Wray
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyv/etcd",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Etcd storage adapter for Keyv",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "xo && nyc ava",
|
|
7
|
+
"test": "xo && nyc ava --serial",
|
|
8
8
|
"coverage": "nyc report --reporter=text-lcov > coverage.lcov",
|
|
9
9
|
"clean": "rm -rf node_modules && rm -rf .nyc_output && rm -rf coverage.lcov"
|
|
10
10
|
},
|
|
@@ -13,12 +13,26 @@
|
|
|
13
13
|
"unicorn/prefer-module": 0,
|
|
14
14
|
"unicorn/no-array-reduce": 0,
|
|
15
15
|
"unicorn/prefer-object-from-entries": 0,
|
|
16
|
-
"unicorn/prefer-node-protocol": 0
|
|
16
|
+
"unicorn/prefer-node-protocol": 0,
|
|
17
|
+
"ava/no-ignored-test-files": [
|
|
18
|
+
"error",
|
|
19
|
+
{
|
|
20
|
+
"extensions": [
|
|
21
|
+
"js",
|
|
22
|
+
"ts"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
]
|
|
17
26
|
}
|
|
18
27
|
},
|
|
19
28
|
"ava": {
|
|
20
29
|
"require": [
|
|
21
|
-
"requirable"
|
|
30
|
+
"requirable",
|
|
31
|
+
"ts-node/register"
|
|
32
|
+
],
|
|
33
|
+
"extensions": [
|
|
34
|
+
"js",
|
|
35
|
+
"ts"
|
|
22
36
|
]
|
|
23
37
|
},
|
|
24
38
|
"repository": {
|
|
@@ -43,23 +57,26 @@
|
|
|
43
57
|
},
|
|
44
58
|
"homepage": "https://github.com/jaredwray/keyv",
|
|
45
59
|
"dependencies": {
|
|
46
|
-
"cockatiel": "^
|
|
60
|
+
"cockatiel": "^3.0.0",
|
|
47
61
|
"etcd3": "^1.1.0",
|
|
48
62
|
"pify": "^5.0.0"
|
|
49
63
|
},
|
|
50
64
|
"devDependencies": {
|
|
51
65
|
"@keyv/test-suite": "*",
|
|
52
|
-
"
|
|
66
|
+
"@types/keyv": "^3.1.4",
|
|
67
|
+
"ava": "^4.3.1",
|
|
53
68
|
"keyv": "*",
|
|
54
69
|
"nyc": "^15.1.0",
|
|
55
70
|
"requirable": "^1.0.5",
|
|
56
71
|
"this": "^1.1.0",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
72
|
+
"ts-node": "^10.9.1",
|
|
73
|
+
"tsd": "^0.22.0",
|
|
74
|
+
"typescript": "^4.7.4",
|
|
75
|
+
"webpack": "^5.74.0",
|
|
76
|
+
"xo": "^0.51.0"
|
|
60
77
|
},
|
|
61
|
-
"tsd"
|
|
62
|
-
"directory"
|
|
78
|
+
"tsd": {
|
|
79
|
+
"directory": "test"
|
|
63
80
|
},
|
|
64
81
|
"types": "./src/index.d.ts",
|
|
65
82
|
"files": [
|
package/src/index.d.ts
CHANGED
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
import {EventEmitter} from 'events';
|
|
2
2
|
import Etcd3 from 'etcd3';
|
|
3
|
+
import {Store, StoredData} from 'keyv';
|
|
3
4
|
|
|
4
|
-
declare class KeyvEtcd extends EventEmitter {
|
|
5
|
+
declare class KeyvEtcd extends EventEmitter implements Store<Value> {
|
|
5
6
|
ttlSupport: any;
|
|
6
7
|
opts: any;
|
|
7
8
|
client: Etcd3;
|
|
8
9
|
lease: import('etcd3').Lease;
|
|
9
|
-
constructor(
|
|
10
|
-
get(key: string): Promise<
|
|
11
|
-
getMany(
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
constructor(options?: string | KeyvEtcd.Options);
|
|
11
|
+
get(key: string): Promise<Value>;
|
|
12
|
+
getMany?(
|
|
13
|
+
keys: string[]
|
|
14
|
+
): Array<StoredData<Value>> | Promise<Array<StoredData<Value>>> | undefined;
|
|
15
|
+
set(key: string, value: Value, ttl?: number): any;
|
|
16
|
+
delete(key: string): boolean | Promise<boolean>;
|
|
14
17
|
deleteMany(keys: string[]): boolean;
|
|
15
|
-
clear(): Promise<void>;
|
|
18
|
+
clear(): void | Promise<void>;
|
|
16
19
|
iterator(namespace: string | undefined): AsyncGenerator<any, void, any>;
|
|
17
|
-
has(key: string): boolean
|
|
20
|
+
has?(key: string): boolean | Promise<boolean>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare namespace KeyvEtcd {
|
|
24
|
+
interface Options {
|
|
25
|
+
url?: string | undefined;
|
|
26
|
+
uri?: string | undefined;
|
|
27
|
+
ttl?: number | undefined;
|
|
28
|
+
}
|
|
18
29
|
}
|
|
19
30
|
|
|
20
31
|
export = KeyvEtcd;
|
package/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const EventEmitter = require('events');
|
|
4
4
|
const {Etcd3} = require('etcd3');
|
|
5
|
-
const {
|
|
5
|
+
const {handleAll, retry, ExponentialBackoff} = require('cockatiel');
|
|
6
6
|
|
|
7
7
|
class KeyvEtcd extends EventEmitter {
|
|
8
8
|
constructor(url, options) {
|
|
@@ -18,7 +18,7 @@ class KeyvEtcd extends EventEmitter {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
if (url.ttl) {
|
|
21
|
-
this.ttlSupport = typeof url.ttl === 'number'
|
|
21
|
+
this.ttlSupport = typeof url.ttl === 'number';
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
this.opts = {
|
|
@@ -28,7 +28,7 @@ class KeyvEtcd extends EventEmitter {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
this.opts.url = this.opts.url.replace(/^etcd:\/\//, '');
|
|
31
|
-
const policy =
|
|
31
|
+
const policy = retry(handleAll, {backoff: new ExponentialBackoff()});
|
|
32
32
|
policy.onFailure(error => {
|
|
33
33
|
this.emit('error', error.reason);
|
|
34
34
|
});
|
|
@@ -70,7 +70,7 @@ class KeyvEtcd extends EventEmitter {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
return data
|
|
73
|
+
return data;
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -106,6 +106,10 @@ class KeyvEtcd extends EventEmitter {
|
|
|
106
106
|
has(key) {
|
|
107
107
|
return this.client.get(key).exists();
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
disconnect() {
|
|
111
|
+
return this.client.close();
|
|
112
|
+
}
|
|
109
113
|
}
|
|
110
114
|
|
|
111
115
|
module.exports = KeyvEtcd;
|