Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions dev/tool/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
} from '@hcengineering/postgres'
import { type DBDoc } from '@hcengineering/postgres/types/utils'
import { getTransactorEndpoint } from '@hcengineering/server-client'
import { sharedPipelineContextVars } from '@hcengineering/server-pipeline'
import { generateToken } from '@hcengineering/server-token'
import { connect } from '@hcengineering/server-tool'
import { type MongoClient } from 'mongodb'
Expand All @@ -57,7 +56,7 @@ export async function moveFromMongoToPG (
}
const client = getMongoClient(mongoUrl)
const mongo = await client.getClient()
const pg = getDBClient(sharedPipelineContextVars, dbUrl)
const pg = getDBClient(dbUrl)
const pgClient = await pg.getClient()

for (let index = 0; index < workspaces.length; index++) {
Expand Down Expand Up @@ -181,7 +180,7 @@ export async function moveWorkspaceFromMongoToPG (
}
const client = getMongoClient(mongoUrl)
const mongo = await client.getClient()
const pg = getDBClient(sharedPipelineContextVars, dbUrl)
const pg = getDBClient(dbUrl)
const pgClient = await pg.getClient()

await moveWorkspace(accountDb, mongo, pgClient, ws, region, include, force)
Expand Down Expand Up @@ -530,7 +529,7 @@ export async function migrateCreatedModifiedBy (
progressMade = false
connectsCount++

pg = getDBClient(sharedPipelineContextVars, dbUrl)
pg = getDBClient(dbUrl)
pgClient = await pg.getClient()

// Expect temp table with mapping to be created manually
Expand Down Expand Up @@ -907,7 +906,7 @@ export async function migrateMergedAccounts (
throw new Error('Only CockroachDB is supported')
}

const pg = getDBClient(sharedPipelineContextVars, dbUrl)
const pg = getDBClient(dbUrl)
const pgClient = await pg.getClient()
const token = getToolToken()

Expand Down Expand Up @@ -1020,7 +1019,7 @@ export async function filterMergedAccountsInMembers (
throw new Error('Only CockroachDB is supported')
}

const pg = getDBClient(sharedPipelineContextVars, dbUrl)
const pg = getDBClient(dbUrl)
const pgClient = await pg.getClient()

try {
Expand Down Expand Up @@ -1083,7 +1082,7 @@ export async function ensureGlobalPersonsForLocalAccounts (
throw new Error('Only CockroachDB is supported')
}

const pg = getDBClient(sharedPipelineContextVars, dbUrl)
const pg = getDBClient(dbUrl)
const pgClient = await pg.getClient()
const token = getToolToken()

Expand Down
9 changes: 3 additions & 6 deletions dev/tool/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ import {
registerServerPlugins,
registerStringLoaders,
registerTxAdapterFactory,
setAdapterSecurity,
sharedPipelineContextVars
setAdapterSecurity
} from '@hcengineering/server-pipeline'
import serverToken, { generateToken } from '@hcengineering/server-token'
import { createWorkspace, upgradeWorkspace } from '@hcengineering/workspace-service'
Expand Down Expand Up @@ -134,10 +133,10 @@ const colorConstants = {

// Register close on process exit.
process.on('exit', () => {
shutdownPostgres(sharedPipelineContextVars).catch((err) => {
shutdownPostgres().catch((err) => {
console.error(err)
})
shutdownMongo(sharedPipelineContextVars).catch((err) => {
shutdownMongo().catch((err) => {
console.error(err)
})
})
Expand Down Expand Up @@ -663,7 +662,6 @@ export function devTool (
// },
// cmd.region,
// 5000, // 5 gigabytes per blob
// sharedPipelineContextVars,
// async (storage, workspaceStorage) => {
// if (cmd.remove) {
// await updateArchiveInfo(toolCtx, db, ws.workspace, true)
Expand Down Expand Up @@ -783,7 +781,6 @@ export function devTool (
// },
// cmd.region,
// 100,
// sharedPipelineContextVars
// )
// ) {
// processed++
Expand Down
8 changes: 2 additions & 6 deletions dev/tool/src/markup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ import { getDBClient } from '@hcengineering/postgres'
import { withRetry } from '@hcengineering/retry'
import { getAccountClient } from '@hcengineering/server-client'
import { type PipelineFactory, type StorageAdapter, createDummyStorageAdapter } from '@hcengineering/server-core'
import {
createBackupPipeline,
createEmptyBroadcastOps,
sharedPipelineContextVars
} from '@hcengineering/server-pipeline'
import { createBackupPipeline, createEmptyBroadcastOps } from '@hcengineering/server-pipeline'
import { generateToken } from '@hcengineering/server-token'
import { isEmptyMarkup } from '@hcengineering/text-core'

Expand Down Expand Up @@ -396,7 +392,7 @@ export async function restoreMarkupRefs (
usePassedCtx: true
})

const pg = getDBClient(sharedPipelineContextVars, dbUrl)
const pg = getDBClient(dbUrl)
const pgClient = await pg.getClient()

try {
Expand Down
10 changes: 4 additions & 6 deletions pods/backup/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import {
registerAdapterFactory,
registerDestroyFactory,
registerTxAdapterFactory,
setAdapterSecurity,
sharedPipelineContextVars
setAdapterSecurity
} from '@hcengineering/server-pipeline'
import { join } from 'path'

Expand All @@ -47,10 +46,10 @@ const model = JSON.parse(readFileSync(process.env.MODEL_JSON ?? 'model.json').to

// Register close on process exit.
process.on('exit', () => {
shutdownPostgres(sharedPipelineContextVars).catch((err) => {
shutdownPostgres().catch((err) => {
console.error(err)
})
shutdownMongo(sharedPipelineContextVars).catch((err) => {
shutdownMongo().catch((err) => {
console.error(err)
})
})
Expand Down Expand Up @@ -103,6 +102,5 @@ startBackup(
externalStorage,
disableTriggers: true
})
},
sharedPipelineContextVars
}
)
7 changes: 3 additions & 4 deletions pods/fulltext/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ import {
registerServerPlugins,
registerStringLoaders,
registerTxAdapterFactory,
setAdapterSecurity,
sharedPipelineContextVars
setAdapterSecurity
} from '@hcengineering/server-pipeline'
import serverToken, { decodeToken } from '@hcengineering/server-token'
import cors from '@koa/cors'
Expand Down Expand Up @@ -71,10 +70,10 @@ interface Reindex {
}
// Register close on process exit.
process.on('exit', () => {
shutdownPostgres(sharedPipelineContextVars).catch((err) => {
shutdownPostgres().catch((err) => {
console.error(err)
})
shutdownMongo(sharedPipelineContextVars).catch((err) => {
shutdownMongo().catch((err) => {
console.error(err)
})
})
Expand Down
7 changes: 3 additions & 4 deletions pods/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import {
registerServerPlugins,
registerStringLoaders,
registerTxAdapterFactory,
setAdapterSecurity,
sharedPipelineContextVars
setAdapterSecurity
} from '@hcengineering/server-pipeline'

import {
Expand All @@ -59,10 +58,10 @@ registerStringLoaders()

// Register close on process exit.
process.on('exit', () => {
shutdownPostgres(sharedPipelineContextVars).catch((err) => {
shutdownPostgres().catch((err) => {
console.error(err)
})
shutdownMongo(sharedPipelineContextVars).catch((err) => {
shutdownMongo().catch((err) => {
console.error(err)
})
})
Expand Down
5 changes: 5 additions & 0 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,11 @@
"projectFolder": "server/postgres",
"shouldPublish": false
},
{
"packageName": "@hcengineering/postgres-base",
"projectFolder": "server/postgres-base",
"shouldPublish": false
},
{
"packageName": "@hcengineering/elastic",
"projectFolder": "server/elastic",
Expand Down
3 changes: 1 addition & 2 deletions server/account/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import { pbkdf2Sync, randomBytes } from 'crypto'
import otpGenerator from 'otp-generator'

import { Analytics } from '@hcengineering/analytics'
import { sharedPipelineContextVars } from '@hcengineering/server-pipeline'
import { decodeTokenVerbose, generateToken, TokenError } from '@hcengineering/server-token'
import { MongoAccountDB } from './collections/mongo'
import { PostgresAccountDB } from './collections/postgres/postgres'
Expand Down Expand Up @@ -93,7 +92,7 @@ export async function getAccountDB (
application_name: appName
}
})
const client = getDBClient(sharedPipelineContextVars, uri)
const client = getDBClient(uri)
const pgClient = await client.getClient()
const pgAccount = new PostgresAccountDB(pgClient, dbNs ?? 'global_account')

Expand Down
7 changes: 2 additions & 5 deletions server/backup-service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ export function startBackup (
workspace: WorkspaceIds,
branding: Branding | null,
externalStorage: StorageAdapter
) => DbConfiguration,
contextVars: Record<string, any>
) => DbConfiguration
): void {
const config = _config()
setMetadata(serverToken.metadata.Secret, config.Secret)
Expand Down Expand Up @@ -66,8 +65,7 @@ export function startBackup (
(ctx, workspace, branding, externalStorage) => {
return getConfig(ctx, mainDbUrl, workspace, branding, externalStorage)
},
config.Region,
contextVars
config.Region
)

process.on('SIGINT', shutdown)
Expand Down Expand Up @@ -129,7 +127,6 @@ export async function backupWorkspace (
region,
downloadLimit,
[],
contextVars,
fullCheck
)
if (result && onFinish !== undefined) {
Expand Down
17 changes: 2 additions & 15 deletions server/backup/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class BackupWorker {
externalStorage: StorageAdapter
) => DbConfiguration,
readonly region: string,
readonly contextVars: Record<string, any>,
readonly skipDomains: string[] = [],
readonly fullCheck: boolean = false
) {
Expand Down Expand Up @@ -324,15 +323,14 @@ class BackupWorker {
const modelDb = new ModelDb(hierarchy)
const txAdapter = await adapterConf.factory(
ctx,
this.contextVars,
hierarchy,
adapterConf.url,
wsIds,
modelDb,
this.workspaceStorageAdapter
)
try {
await txAdapter.init?.(ctx, this.contextVars)
await txAdapter.init?.(ctx, {})

return (
await txAdapter.rawFindAll<Tx>(
Expand Down Expand Up @@ -418,18 +416,9 @@ export function backupService (
externalStorage: StorageAdapter
) => DbConfiguration,
region: string,
contextVars: Record<string, any>,
recheck?: boolean
): () => void {
const backupWorker = new BackupWorker(
storage,
config,
pipelineFactory,
workspaceStorageAdapter,
getConfig,
region,
contextVars
)
const backupWorker = new BackupWorker(storage, config, pipelineFactory, workspaceStorageAdapter, getConfig, region)

const shutdown = (): void => {
void backupWorker.close()
Expand All @@ -455,7 +444,6 @@ export async function doBackupWorkspace (
region: string,
downloadLimit: number,
skipDomains: string[],
contextVars: Record<string, any>,
fullCheck: boolean = false,
notify?: (progress: number) => Promise<void>
): Promise<boolean> {
Expand All @@ -466,7 +454,6 @@ export async function doBackupWorkspace (
workspaceStorageAdapter,
getConfig,
region,
contextVars,
skipDomains,
fullCheck
)
Expand Down
Loading
Loading