clickhouse-ts
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -23,2 +23,7 @@ /// <reference types="node" /> | ||
}>; | ||
/** | ||
* Разрешение всех чанков прямо сейчас | ||
* Необходимо для обеспечения целостности данных при непредвиденных ошбках | ||
*/ | ||
gracefulShutdown(codeOrSignal?: any): Promise<void>; | ||
} |
@@ -16,3 +16,3 @@ "use strict"; | ||
}; | ||
var _NodeJSCacheManager_tableChunks, _NodeJSCacheManager_chunkResolver, _NodeJSCacheManager_splitter, _NodeJSCacheManager_options, _NodeJSCacheManager_exploreChunks, _NodeJSCacheManager_withGrasefulShutdown, _NodeJSCacheManager_resolveChunk, _NodeJSCacheManager_createChunk, _NodeJSCacheManager_deleteChunk, _NodeJSCacheManager_getChunk; | ||
var _NodeJSCacheManager_tableChunks, _NodeJSCacheManager_chunkResolver, _NodeJSCacheManager_splitter, _NodeJSCacheManager_options, _NodeJSCacheManager_exploreChunks, _NodeJSCacheManager_resolveChunk, _NodeJSCacheManager_createChunk, _NodeJSCacheManager_deleteChunk, _NodeJSCacheManager_getChunk; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -60,24 +60,2 @@ exports.NodeJSCacheManager = void 0; | ||
/** | ||
* Разрешение всех чанков прямо сейчас | ||
* Необходимо для обеспечения целостности данных при непредвиденных ошбках | ||
*/ | ||
); | ||
/** | ||
* Разрешение всех чанков прямо сейчас | ||
* Необходимо для обеспечения целостности данных при непредвиденных ошбках | ||
*/ | ||
_NodeJSCacheManager_withGrasefulShutdown.set(this, () => { | ||
const gracefulShutdown = async (event) => { | ||
Debug_1.debug.log('panic.critical', `[${event}] Crytycal occured. Imeddiately resolving all in-memory rows`); | ||
if (__classPrivateFieldGet(this, _NodeJSCacheManager_chunkResolver, "f")) | ||
clearInterval(__classPrivateFieldGet(this, _NodeJSCacheManager_chunkResolver, "f")); | ||
const immediately = true; | ||
await __classPrivateFieldGet(this, _NodeJSCacheManager_exploreChunks, "f").call(this, immediately); | ||
}; | ||
process.on('SIGTERM', async () => await gracefulShutdown('SIGTERM')); // graceful shutdown for kubernetes | ||
process.on('SIGINT', async () => await gracefulShutdown('SIGINT')); // manual interruping | ||
process.on('beforeExit', async () => await gracefulShutdown('beforeExit')); // handling other events | ||
process.on('exit', async () => await gracefulShutdown('exit')); // handle if nothing not workes | ||
} | ||
/** | ||
* При определенных условиях эта функция может быть вызвана, | ||
@@ -203,3 +181,2 @@ * вследствие чего конкретный chunk конкретной таблицы будет разрешен | ||
__classPrivateFieldSet(this, _NodeJSCacheManager_chunkResolver, setInterval(async () => await __classPrivateFieldGet(this, _NodeJSCacheManager_exploreChunks, "f").call(this), intervalTime), "f"); | ||
__classPrivateFieldGet(this, _NodeJSCacheManager_withGrasefulShutdown, "f").call(this); | ||
} | ||
@@ -225,4 +202,15 @@ /** | ||
} | ||
/** | ||
* Разрешение всех чанков прямо сейчас | ||
* Необходимо для обеспечения целостности данных при непредвиденных ошбках | ||
*/ | ||
async gracefulShutdown(codeOrSignal = '') { | ||
Debug_1.debug.log('panic.critical', `[${codeOrSignal}] Crytycal occured. Imeddiately resolving all in-memory rows`); | ||
if (__classPrivateFieldGet(this, _NodeJSCacheManager_chunkResolver, "f")) | ||
clearInterval(__classPrivateFieldGet(this, _NodeJSCacheManager_chunkResolver, "f")); | ||
const immediately = true; | ||
await __classPrivateFieldGet(this, _NodeJSCacheManager_exploreChunks, "f").call(this, immediately); | ||
} | ||
} | ||
exports.NodeJSCacheManager = NodeJSCacheManager; | ||
_NodeJSCacheManager_tableChunks = new WeakMap(), _NodeJSCacheManager_chunkResolver = new WeakMap(), _NodeJSCacheManager_splitter = new WeakMap(), _NodeJSCacheManager_options = new WeakMap(), _NodeJSCacheManager_exploreChunks = new WeakMap(), _NodeJSCacheManager_withGrasefulShutdown = new WeakMap(), _NodeJSCacheManager_resolveChunk = new WeakMap(), _NodeJSCacheManager_createChunk = new WeakMap(), _NodeJSCacheManager_deleteChunk = new WeakMap(), _NodeJSCacheManager_getChunk = new WeakMap(); | ||
_NodeJSCacheManager_tableChunks = new WeakMap(), _NodeJSCacheManager_chunkResolver = new WeakMap(), _NodeJSCacheManager_splitter = new WeakMap(), _NodeJSCacheManager_options = new WeakMap(), _NodeJSCacheManager_exploreChunks = new WeakMap(), _NodeJSCacheManager_resolveChunk = new WeakMap(), _NodeJSCacheManager_createChunk = new WeakMap(), _NodeJSCacheManager_deleteChunk = new WeakMap(), _NodeJSCacheManager_getChunk = new WeakMap(); |
@@ -20,2 +20,3 @@ /// <reference types="node" /> | ||
}>; | ||
gracefulShutdown(): Promise<void>; | ||
} |
@@ -154,4 +154,7 @@ "use strict"; | ||
} | ||
async gracefulShutdown() { | ||
console.warn('Redis gracefulShutdown is not implemented'); | ||
} | ||
} | ||
exports.RedisCacheManager = RedisCacheManager; | ||
_RedisCacheManager_tableChunks = new WeakMap(), _RedisCacheManager_instance = new WeakMap(), _RedisCacheManager_chunkResolver = new WeakMap(), _RedisCacheManager_splitter = new WeakMap(), _RedisCacheManager_options = new WeakMap(), _RedisCacheManager_checkChunks = new WeakMap(), _RedisCacheManager_resolveChunk = new WeakMap(), _RedisCacheManager_createChunk = new WeakMap(), _RedisCacheManager_deleteChunk = new WeakMap(), _RedisCacheManager_getChunk = new WeakMap(); |
@@ -36,2 +36,3 @@ import { Redis } from 'ioredis'; | ||
}>; | ||
cleanupChunks(): Promise<void>; | ||
} |
@@ -204,4 +204,10 @@ "use strict"; | ||
} | ||
async cleanupChunks() { | ||
if (!__classPrivateFieldGet(this, _Clickhouse_cacheManager, "f")) { | ||
throw new Error('CacheClient is not implemented'); | ||
} | ||
await __classPrivateFieldGet(this, _Clickhouse_cacheManager, "f").gracefulShutdown(); | ||
} | ||
} | ||
exports.Clickhouse = Clickhouse; | ||
_Clickhouse_httpClient = new WeakMap(), _Clickhouse_options = new WeakMap(), _Clickhouse_defaultValues = new WeakMap(), _Clickhouse_cacheManager = new WeakMap(), _Clickhouse_onChunkCb = new WeakMap(), _Clickhouse_redisClient = new WeakMap(), _Clickhouse_isFirstInsert = new WeakMap(); |
@@ -12,3 +12,3 @@ { | ||
], | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"license": "ISC", | ||
@@ -15,0 +15,0 @@ "description": "Clickhouse client on TypeScript using redis caching queries", |
@@ -40,3 +40,2 @@ import dayjs from 'dayjs' | ||
this.#chunkResolver = setInterval(async () => await this.#exploreChunks(), intervalTime) | ||
this.#withGrasefulShutdown() | ||
} | ||
@@ -74,20 +73,2 @@ | ||
/** | ||
* Разрешение всех чанков прямо сейчас | ||
* Необходимо для обеспечения целостности данных при непредвиденных ошбках | ||
*/ | ||
readonly #withGrasefulShutdown = () => { | ||
const gracefulShutdown = async (event: string) => { | ||
debug.log('panic.critical', `[${event}] Crytycal occured. Imeddiately resolving all in-memory rows`) | ||
if (this.#chunkResolver) clearInterval(this.#chunkResolver) | ||
const immediately = true | ||
await this.#exploreChunks(immediately) | ||
} | ||
process.on('SIGTERM', async () => await gracefulShutdown('SIGTERM')) // graceful shutdown for kubernetes | ||
process.on('SIGINT', async () => await gracefulShutdown('SIGINT')) // manual interruping | ||
process.on('beforeExit', async () => await gracefulShutdown('beforeExit')) // handling other events | ||
process.on('exit', async () => await gracefulShutdown('exit')) // handle if nothing not workes | ||
} | ||
/** | ||
* При определенных условиях эта функция может быть вызвана, | ||
@@ -197,2 +178,13 @@ * вследствие чего конкретный chunk конкретной таблицы будет разрешен | ||
} | ||
/** | ||
* Разрешение всех чанков прямо сейчас | ||
* Необходимо для обеспечения целостности данных при непредвиденных ошбках | ||
*/ | ||
public async gracefulShutdown (codeOrSignal: any = '') { | ||
debug.log('panic.critical', `[${codeOrSignal}] Crytycal occured. Imeddiately resolving all in-memory rows`) | ||
if (this.#chunkResolver) clearInterval(this.#chunkResolver) | ||
const immediately = true | ||
await this.#exploreChunks(immediately) | ||
} | ||
} |
@@ -193,2 +193,6 @@ import dayjs from "dayjs"; | ||
} | ||
public async gracefulShutdown () { | ||
console.warn('Redis gracefulShutdown is not implemented') | ||
} | ||
} |
@@ -250,2 +250,9 @@ import sqlstring from 'sqlstring' | ||
} | ||
public async cleanupChunks() { | ||
if (!this.#cacheManager) { | ||
throw new Error('CacheClient is not implemented') | ||
} | ||
await this.#cacheManager.gracefulShutdown() | ||
} | ||
} |
1643
83005