feat: use retry function
This commit is contained in:
parent
6235186ff9
commit
dfd927eeb4
1 changed files with 30 additions and 27 deletions
|
|
@ -46,6 +46,7 @@ import {
|
||||||
} from "../services/permission";
|
} from "../services/permission";
|
||||||
import { connectOrDisconnect, connectOrNot, whereAddressQuery } from "../utils/relation";
|
import { connectOrDisconnect, connectOrNot, whereAddressQuery } from "../utils/relation";
|
||||||
import { isUsedError, notFoundError, relationError } from "../utils/error";
|
import { isUsedError, notFoundError, relationError } from "../utils/error";
|
||||||
|
import { retry } from "../utils/func";
|
||||||
|
|
||||||
if (!process.env.MINIO_BUCKET) {
|
if (!process.env.MINIO_BUCKET) {
|
||||||
throw Error("Require MinIO bucket.");
|
throw Error("Require MinIO bucket.");
|
||||||
|
|
@ -174,7 +175,8 @@ const permissionCond = createPermCondition(globalAllow);
|
||||||
const permissionCheck = createPermCheck(globalAllow);
|
const permissionCheck = createPermCheck(globalAllow);
|
||||||
|
|
||||||
async function userBranchCodeGen(user: User, branch: Branch) {
|
async function userBranchCodeGen(user: User, branch: Branch) {
|
||||||
return await prisma.$transaction(
|
return await retry(() =>
|
||||||
|
prisma.$transaction(
|
||||||
async (tx) => {
|
async (tx) => {
|
||||||
const typ = user.userType;
|
const typ = user.userType;
|
||||||
|
|
||||||
|
|
@ -204,6 +206,7 @@ async function userBranchCodeGen(user: User, branch: Branch) {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
{ isolationLevel: Prisma.TransactionIsolationLevel.Serializable },
|
{ isolationLevel: Prisma.TransactionIsolationLevel.Serializable },
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue