api: make deepsource happy
This commit is contained in:
parent
90d57ab6ea
commit
5a66af514e
4 changed files with 21 additions and 17 deletions
|
@ -117,6 +117,10 @@ const formatKeys = (keyData) => {
|
||||||
return formatted;
|
return formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateKeys = (newKeys) => {
|
||||||
|
keys = formatKeys(newKeys);
|
||||||
|
}
|
||||||
|
|
||||||
const loadKeys = async (source) => {
|
const loadKeys = async (source) => {
|
||||||
let updated;
|
let updated;
|
||||||
if (source.protocol === 'file:') {
|
if (source.protocol === 'file:') {
|
||||||
|
@ -138,10 +142,6 @@ const loadKeys = async (source) => {
|
||||||
updateKeys(updated);
|
updateKeys(updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateKeys = (newKeys) => {
|
|
||||||
keys = formatKeys(newKeys);
|
|
||||||
}
|
|
||||||
|
|
||||||
const wrapLoad = (url, initial = false) => {
|
const wrapLoad = (url, initial = false) => {
|
||||||
loadKeys(url)
|
loadKeys(url)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|
|
@ -15,15 +15,19 @@ export const syncSecrets = () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (cluster.isPrimary) {
|
if (cluster.isPrimary) {
|
||||||
let remaining = Object.values(cluster.workers).length;
|
let remaining = Object.values(cluster.workers).length;
|
||||||
|
const handleReady = (worker, m) => {
|
||||||
for (const worker of Object.values(cluster.workers)) {
|
|
||||||
worker.once('message', (m) => {
|
|
||||||
if (m.ready)
|
if (m.ready)
|
||||||
worker.send({ rateSalt, streamSalt });
|
worker.send({ rateSalt, streamSalt });
|
||||||
|
|
||||||
if (!--remaining)
|
if (!--remaining)
|
||||||
resolve();
|
resolve();
|
||||||
});
|
}
|
||||||
|
|
||||||
|
for (const worker of Object.values(cluster.workers)) {
|
||||||
|
worker.once(
|
||||||
|
'message',
|
||||||
|
(m) => handleReady(worker, m)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else if (cluster.isWorker) {
|
} else if (cluster.isWorker) {
|
||||||
if (rateSalt || streamSalt)
|
if (rateSalt || streamSalt)
|
||||||
|
|
|
@ -13,7 +13,7 @@ export class Store {
|
||||||
this.id = name;
|
this.id = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _has(_key) { throw "needs implementation" }
|
async _has(_key) { await Promise.reject("needs implementation"); }
|
||||||
has(key) {
|
has(key) {
|
||||||
if (typeof key !== 'string') {
|
if (typeof key !== 'string') {
|
||||||
key = key.toString();
|
key = key.toString();
|
||||||
|
@ -22,7 +22,7 @@ export class Store {
|
||||||
return this._has(key);
|
return this._has(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _get(_key) { throw "needs implementation" }
|
async _get(_key) { await Promise.reject("needs implementation"); }
|
||||||
async get(key) {
|
async get(key) {
|
||||||
if (typeof key !== 'string') {
|
if (typeof key !== 'string') {
|
||||||
key = key.toString();
|
key = key.toString();
|
||||||
|
@ -35,7 +35,7 @@ export class Store {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _set(_key, _val, _exp_sec = -1) { throw "needs implementation" }
|
async _set(_key, _val, _exp_sec = -1) { await Promise.reject("needs implementation") }
|
||||||
set(key, val, exp_sec = -1) {
|
set(key, val, exp_sec = -1) {
|
||||||
if (typeof key !== 'string') {
|
if (typeof key !== 'string') {
|
||||||
key = key.toString();
|
key = key.toString();
|
||||||
|
|
|
@ -14,17 +14,17 @@ export default class MemoryStore extends Store {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _has(key) {
|
_has(key) {
|
||||||
return this.#store.has(key);
|
return this.#store.has(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _get(key) {
|
_get(key) {
|
||||||
const val = this.#store.get(key);
|
const val = this.#store.get(key);
|
||||||
|
|
||||||
return val === undefined ? null : val;
|
return val === undefined ? null : val;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _set(key, val, exp_sec = -1) {
|
_set(key, val, exp_sec = -1) {
|
||||||
if (this.#store.has(key)) {
|
if (this.#store.has(key)) {
|
||||||
this.#timeouts.remove(o => o.k === key);
|
this.#timeouts.remove(o => o.k === key);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue