remove mutex (#7056)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2024-10-30 20:51:18 +07:00
committed by GitHub
parent 1b7d559180
commit e4bf53ad1b
8 changed files with 75 additions and 88 deletions
+5 -2
View File
@@ -23,9 +23,12 @@ export class ConnectionMgrMiddleware extends BaseMiddleware implements Middlewar
if (ctx.id === undefined) {
ctx.id = generateId()
}
ctx.onEnd = async (_ctx: MeasureContext) => {
await this.context.adapterManager?.closeContext?.(_ctx)
}
const result = await this.provideTx(ctx, tx)
this.context.endContext = async (_ctx: MeasureContext) => {
await this.context.adapterManager?.closeContext?.(ctx)
if (ctx.onEnd !== undefined) {
await ctx.onEnd(ctx)
}
return result
}
+10 -4
View File
@@ -33,6 +33,7 @@ import core, {
type TxRemoveDoc,
type TxUpdateDoc,
addOperation,
generateId,
toFindResult,
withContext
} from '@hcengineering/core'
@@ -225,11 +226,16 @@ export class TriggersMiddleware extends BaseMiddleware implements Middleware {
)
if (aresult.length > 0) {
await this.processDerivedTxes(ctx, aresult)
// We need to send all to recipients
await this.context.head?.handleBroadcast(ctx)
await ctx.with('process-aync-result', {}, async (ctx) => {
ctx.id = generateId()
await this.processDerivedTxes(ctx, aresult)
// We need to send all to recipients
await this.context.head?.handleBroadcast(ctx)
if (ctx.onEnd !== undefined) {
await ctx.onEnd(ctx)
}
})
}
await this.context.endContext?.(ctx)
}
private async processDerivedTxes (ctx: MeasureContext<SessionData>, derived: Tx[]): Promise<void> {