oak-backend-base/lib/Synchronizer.d.ts

39 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { EntityDict, StorageSchema, EndpointItem } from 'oak-domain/lib/types';
import { VolatileTrigger } from 'oak-domain/lib/types/Trigger';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { BackendRuntimeContext } from 'oak-frontend-base/lib/context/BackendRuntimeContext';
import { SyncConfigWrapper } from './types/Sync';
export default class Synchronizer<ED extends EntityDict & BaseEntityDict, Cxt extends BackendRuntimeContext<ED>> {
private config;
private schema;
private selfEncryptInfo?;
private remotePullInfoMap;
private pullMaxBornAtMap;
private remotePushChannel;
/**
* 向某一个远端对象push opers。根据幂等性这里如果失败了必须反复推送
* @param channel
* @param retry
*/
private pushOnChannel;
/**
* 推向远端Node的oper需要严格保证按产生的时间序推送。根据幂等原理这里必须要推送成功
* 因此在这里要实现两点:
* 1oper如果推送失败了必须留存在queue中以保证在后面产生的oper之前推送
* 2当对queue中增加oper时要检查是否有重有重说明之前失败过如果无重则将之放置在队列尾
*
* 其实这里还无法严格保证先产生的oper一定先到达被推送因为volatile trigger是在事务提交后再发生的但这种情况在目前应该跑不出来在实际执行oper的时候assert掉先。by Xc 20240226
*/
private pushOper;
private getSelfEncryptInfo;
private makeCreateOperTrigger;
constructor(config: SyncConfigWrapper<ED, Cxt>, schema: StorageSchema<ED>);
/**
* 根据sync的定义生成对应的 commit triggers
* @returns
*/
getSyncTriggers(): VolatileTrigger<ED, keyof ED, Cxt>[];
private checkOperationConsistent;
getSelfEndpoint(): EndpointItem<ED, Cxt>;
}