修正了synchronizer内部的一些问题,标注了该volatiletrigger为cleanTriggerDataBySelf

This commit is contained in:
Xu Chang 2024-12-25 18:00:21 +08:00
parent 9449a355c8
commit e03d1bb51a
2 changed files with 28 additions and 14 deletions

View File

@ -144,7 +144,7 @@ class Synchronizer {
}
}, {});
const entityIds = operEntityArr.map(ele => ele.entityId);
return onSynchronized({
await onSynchronized({
action: oper.action,
data: oper.data,
rowIds: entityIds,
@ -153,10 +153,8 @@ class Synchronizer {
}, context);
}
}
/**
* 自主将triggerData属性清零
*/
const operIds = queue.map(ele => ele.oper.id);
// 在内部清理相应的triggerData
await context.operate('oper', {
id: await (0, uuid_1.generateNewIdAsync)(),
action: 'update',
@ -359,6 +357,7 @@ class Synchronizer {
}
}));
if (unPushedIds.length > 0) {
// 在内部清理相应的triggerData
await context.operate('oper', {
id: await (0, uuid_1.generateNewIdAsync)(),
action: 'update',
@ -379,9 +378,15 @@ class Synchronizer {
}
}
if (result) {
const exception = result.find(ele => ele instanceof Error);
if (exception) {
throw exception;
const exceptions = result.filter(ele => ele instanceof Error);
if (exceptions.length > 0) {
const notPartialSuccess = exceptions.find(ele => !(ele instanceof types_1.OakPartialSuccess));
if (notPartialSuccess) {
throw notPartialSuccess;
}
else {
console.warn('出现了PartialSuccess部分Oper同步失败事务仍然提交');
}
}
}
}
@ -488,6 +493,7 @@ class Synchronizer {
strict: 'makeSure',
singleton: true,
grouped: true,
cleanTriggerDataBySelf: true,
check: (operation) => {
const { data } = operation;
const { targetEntity, action } = data;

View File

@ -204,7 +204,7 @@ export default class Synchronizer<ED extends EntityDict & BaseEntityDict, Cxt ex
{}
);
const entityIds = operEntityArr.map(ele => ele.entityId!);
return onSynchronized({
await onSynchronized({
action: oper.action!,
data: oper.data!,
rowIds: entityIds,
@ -214,12 +214,10 @@ export default class Synchronizer<ED extends EntityDict & BaseEntityDict, Cxt ex
}
}
/**
* triggerData属性清零
*/
const operIds = queue.map(
ele => ele.oper.id!
);
// 在内部清理相应的triggerData
await context.operate('oper', {
id: await generateNewIdAsync(),
action: 'update',
@ -473,6 +471,7 @@ export default class Synchronizer<ED extends EntityDict & BaseEntityDict, Cxt ex
)
);
if (unPushedIds.length > 0) {
// 在内部清理相应的triggerData
await context.operate('oper', {
id: await generateNewIdAsync(),
action: 'update',
@ -494,9 +493,17 @@ export default class Synchronizer<ED extends EntityDict & BaseEntityDict, Cxt ex
}
if (result) {
const exception = result.find(ele => ele instanceof Error);
if (exception) {
throw exception;
const exceptions = result.filter(ele => ele instanceof Error);
if (exceptions.length > 0) {
const notPartialSuccess = exceptions.find(
ele => !(ele instanceof OakPartialSuccess)
);
if (notPartialSuccess) {
throw notPartialSuccess;
}
else {
console.warn('出现了PartialSuccess部分Oper同步失败事务仍然提交');
}
}
}
}
@ -629,6 +636,7 @@ export default class Synchronizer<ED extends EntityDict & BaseEntityDict, Cxt ex
strict: 'makeSure',
singleton: true,
grouped: true,
cleanTriggerDataBySelf: true,
check: (operation: ED['oper']['Create']) => {
const { data } = operation as ED['oper']['CreateSingle'];
const { targetEntity, action } = data;