UBERF-6202: Use only one mongo pull per configuration (#5073)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2024-03-27 15:19:16 +05:00
committed by GitHub
parent 418b4b1bbd
commit 183239f2fe
5 changed files with 152 additions and 87 deletions
+6 -7
View File
@@ -67,11 +67,10 @@ import {
type Db,
type Document,
type Filter,
type MongoClient,
type Sort,
type UpdateFilter
} from 'mongodb'
import { getMongoClient, getWorkspaceDB } from './utils'
import { getMongoClient, getWorkspaceDB, type MongoClientReference } from './utils'
function translateDoc (doc: Doc): Document {
return { ...doc, '%hash%': null }
@@ -106,7 +105,7 @@ abstract class MongoAdapterBase implements DbAdapter {
protected readonly db: Db,
protected readonly hierarchy: Hierarchy,
protected readonly modelDb: ModelDb,
protected readonly client: MongoClient
protected readonly client: MongoClientReference
) {}
async init (): Promise<void> {}
@@ -1408,8 +1407,8 @@ export async function createMongoAdapter (
workspaceId: WorkspaceId,
modelDb: ModelDb
): Promise<DbAdapter> {
const client = await getMongoClient(url)
const db = getWorkspaceDB(client, workspaceId)
const client = getMongoClient(url)
const db = getWorkspaceDB(await client.getClient(), workspaceId)
return new MongoAdapter(db, hierarchy, modelDb, client)
}
@@ -1423,7 +1422,7 @@ export async function createMongoTxAdapter (
workspaceId: WorkspaceId,
modelDb: ModelDb
): Promise<TxAdapter> {
const client = await getMongoClient(url)
const db = getWorkspaceDB(client, workspaceId)
const client = getMongoClient(url)
const db = getWorkspaceDB(await client.getClient(), workspaceId)
return new MongoTxAdapter(db, hierarchy, modelDb, client)
}