feat(multiregion): apply prepared transactions to projects (#5322)
* feat(multiregion): replace user replication * chore(multiregion): optimise replication * maybe it's this * postgres is fun * once more * chore(multiregion): only replicate test user creation during multiregion tests * feat: improved replicate_query logic * fix: minor * fix: starting issue * feat: included user create and delete specs to multiregion * feat: removed console logs * fix: user defaults * fix: multiregion test helper * fix: update scenarios for users * refactor(multiregion): swap replicateQuery concept to asMultiregionOperation (#5301) feat(multiregion): introduced asMultregionOperator, refactor test to user builder classes * chore: renamings * fix: remove comments * feat: remove user replication * refactor: simplified spec usages * chore: comments * chore: branches and favs * chore: more tests * chore: more tests * fix linting * fix tests * feat: dropping replication * refactor: moved project delete to service * fix: comment * feat: updateStreamFactory and updateProjectFacotry * deleteProjectFactory + replicateFactory * deleteWorkspaceFactory * fix: selector * fix: tests * fix tests, finished createStreamFactory * feat: simplify changes * fix: remove comment * fix: minor strucutres * fix: moveProjectToRegion * fix: moved branch creation outside of multiregion scope * fix: branch creation * fix: tests * fix: ci tests * fix: removed log form test * fix: on specs, no random regionKeys * review fixes * fix: mr comments * feat: removed test --------- Co-authored-by: Charles Driesler <chuck@speckle.systems>
This commit is contained in:
committed by
GitHub
parent
6692fdf4aa
commit
399c998fd7
@@ -147,14 +147,6 @@ export const asMultiregionalOperation = async <T, K extends [Knex, ...Knex[]]>(
|
||||
* @description reference to the main db (first one passed in the array)
|
||||
*/
|
||||
mainDb: Knex
|
||||
/**
|
||||
* @description reference for second db (first one not main)
|
||||
*/
|
||||
regionDb: Knex
|
||||
/**
|
||||
* @description reference for all regions (all dbs except the main one)
|
||||
*/
|
||||
regionDbs: Knex[]
|
||||
emit: EventBusEmit
|
||||
}) => MaybeAsync<T>,
|
||||
params: {
|
||||
@@ -209,8 +201,6 @@ export const asMultiregionalOperation = async <T, K extends [Knex, ...Knex[]]>(
|
||||
result = await operation({
|
||||
mainDb: mainDbTx,
|
||||
allDbs: trxs,
|
||||
regionDb: regionDbsTx[0],
|
||||
regionDbs: regionDbsTx,
|
||||
emit
|
||||
})
|
||||
|
||||
@@ -267,3 +257,20 @@ export const asMultiregionalOperation = async <T, K extends [Knex, ...Knex[]]>(
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper intended to be used with asMultiregionOperation that returns a curried function
|
||||
* to apply a factory built with { db: Knex} to multiple dbs, with same input returning the first result.
|
||||
* @param dbs Knex[]
|
||||
* @param factory a function that recieves a db constructor
|
||||
* @returns the result of the first database
|
||||
*/
|
||||
export function replicateFactory<Args extends unknown[], ReturnType>(
|
||||
dbs: Knex[],
|
||||
factory: (context: { db: Knex }) => (...args: Args) => Promise<ReturnType>
|
||||
): (...args: Args) => Promise<ReturnType> {
|
||||
return async (...args: Args): Promise<ReturnType> => {
|
||||
const [result] = await Promise.all(dbs.map((db) => factory({ db })(...args)))
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user