ydb-qdrant 4.4.0 → 4.5.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 +1 -1
- package/dist/server.d.ts +2 -0
- package/dist/server.js +10 -1
- package/dist/ydb/client.d.ts +2 -0
- package/dist/ydb/client.js +18 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
[](https://www.npmjs.com/package/ydb-qdrant)
|
|
14
14
|
[](https://github.com/users/astandrik/packages/container/package/ydb-qdrant)
|
|
15
|
-
[](https://opensource.org/licenses/Apache-2.0)
|
|
16
16
|
|
|
17
17
|
# YDB Qdrant-compatible Service
|
|
18
18
|
|
package/dist/server.d.ts
CHANGED
package/dist/server.js
CHANGED
|
@@ -2,11 +2,20 @@ import express from "express";
|
|
|
2
2
|
import { collectionsRouter } from "./routes/collections.js";
|
|
3
3
|
import { pointsRouter } from "./routes/points.js";
|
|
4
4
|
import { requestLogger } from "./middleware/requestLogger.js";
|
|
5
|
+
import { isYdbAvailable } from "./ydb/client.js";
|
|
6
|
+
export async function healthHandler(_req, res) {
|
|
7
|
+
const ok = await isYdbAvailable();
|
|
8
|
+
if (!ok) {
|
|
9
|
+
res.status(503).json({ status: "error", error: "YDB unavailable" });
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
res.json({ status: "ok" });
|
|
13
|
+
}
|
|
5
14
|
export function buildServer() {
|
|
6
15
|
const app = express();
|
|
7
16
|
app.use(express.json({ limit: "20mb" }));
|
|
8
17
|
app.use(requestLogger);
|
|
9
|
-
app.get("/health",
|
|
18
|
+
app.get("/health", healthHandler);
|
|
10
19
|
app.use("/collections", collectionsRouter);
|
|
11
20
|
app.use("/collections", pointsRouter);
|
|
12
21
|
return app;
|
package/dist/ydb/client.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ type DriverConfig = {
|
|
|
7
7
|
connectionString?: string;
|
|
8
8
|
authService?: IAuthService;
|
|
9
9
|
};
|
|
10
|
+
export declare function __setDriverForTests(fake: unknown): void;
|
|
10
11
|
export declare function configureDriver(config: DriverConfig): void;
|
|
11
12
|
export declare function readyOrThrow(): Promise<void>;
|
|
12
13
|
export declare function withSession<T>(fn: (s: Session) => Promise<T>): Promise<T>;
|
|
14
|
+
export declare function isYdbAvailable(timeoutMs?: number): Promise<boolean>;
|
package/dist/ydb/client.js
CHANGED
|
@@ -3,8 +3,14 @@ import { YDB_DATABASE, YDB_ENDPOINT } from "../config/env.js";
|
|
|
3
3
|
const require = createRequire(import.meta.url);
|
|
4
4
|
const { Driver, getCredentialsFromEnv, Types, TypedValues, TableDescription, Column, } = require("ydb-sdk");
|
|
5
5
|
export { Types, TypedValues, TableDescription, Column };
|
|
6
|
+
const DRIVER_READY_TIMEOUT_MS = 15000;
|
|
7
|
+
const TABLE_SESSION_TIMEOUT_MS = 20000;
|
|
8
|
+
const YDB_HEALTHCHECK_READY_TIMEOUT_MS = 5000;
|
|
6
9
|
let overrideConfig;
|
|
7
10
|
let driver;
|
|
11
|
+
export function __setDriverForTests(fake) {
|
|
12
|
+
driver = fake;
|
|
13
|
+
}
|
|
8
14
|
export function configureDriver(config) {
|
|
9
15
|
if (driver) {
|
|
10
16
|
// Driver already created; keep existing connection settings.
|
|
@@ -30,12 +36,21 @@ function getOrCreateDriver() {
|
|
|
30
36
|
}
|
|
31
37
|
export async function readyOrThrow() {
|
|
32
38
|
const d = getOrCreateDriver();
|
|
33
|
-
const ok = await d.ready(
|
|
39
|
+
const ok = await d.ready(DRIVER_READY_TIMEOUT_MS);
|
|
34
40
|
if (!ok) {
|
|
35
|
-
throw new Error(
|
|
41
|
+
throw new Error(`YDB driver is not ready in ${DRIVER_READY_TIMEOUT_MS / 1000}s. Check connectivity and credentials.`);
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
export async function withSession(fn) {
|
|
39
45
|
const d = getOrCreateDriver();
|
|
40
|
-
return await d.tableClient.withSession(fn,
|
|
46
|
+
return await d.tableClient.withSession(fn, TABLE_SESSION_TIMEOUT_MS);
|
|
47
|
+
}
|
|
48
|
+
export async function isYdbAvailable(timeoutMs = YDB_HEALTHCHECK_READY_TIMEOUT_MS) {
|
|
49
|
+
const d = getOrCreateDriver();
|
|
50
|
+
try {
|
|
51
|
+
return await d.ready(timeoutMs);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
41
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ydb-qdrant",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"main": "dist/package/api.js",
|
|
5
5
|
"types": "dist/package/api.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"zod"
|
|
47
47
|
],
|
|
48
48
|
"author": "",
|
|
49
|
-
"license": "
|
|
49
|
+
"license": "Apache-2.0",
|
|
50
50
|
"description": "Qdrant-compatible Node.js/TypeScript API that stores/searches embeddings in YDB using single-phase top-k vector search with an automatic vector index and table-scan fallback.",
|
|
51
51
|
"type": "module",
|
|
52
52
|
"publishConfig": {
|