34 lines
1.6 KiB
TypeScript
34 lines
1.6 KiB
TypeScript
import { EntityDict, StorageSchema, EndpointItem, SyncConfig } 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';
|
||
export default class Synchronizer<ED extends EntityDict & BaseEntityDict, Cxt extends BackendRuntimeContext<ED>> {
|
||
private config;
|
||
private schema;
|
||
private remotePullInfoMap;
|
||
private channelDict;
|
||
private contextBuilder;
|
||
private pushAccessMap;
|
||
private startChannel2;
|
||
/**开始同步这些channel上的oper。注意,这时候即使某个channel上失败了,也不应影响本事务提交(其它的channel成功了) */
|
||
private startAllChannel;
|
||
private pushOperToChannel;
|
||
private refineOperData;
|
||
private dispatchOperToChannels;
|
||
/**
|
||
* 为了保证推送的oper序,采用从database中顺序读取所有需要推送的oper来进行推送
|
||
* 每个进程都保证把当前所有的oper顺序处理掉,就不会有乱序的问题,大家通过database上的锁来完成同步
|
||
* @param context
|
||
*/
|
||
private trySynchronizeOpers;
|
||
private makeCreateOperTrigger;
|
||
constructor(config: SyncConfig<ED, Cxt>, schema: StorageSchema<ED>, contextBuilder: () => Cxt);
|
||
/**
|
||
* 根据sync的定义,生成对应的 commit triggers
|
||
* @returns
|
||
*/
|
||
getSyncTriggers(): VolatileTrigger<ED, keyof ED, Cxt>[];
|
||
getSelfEndpoint(): EndpointItem<ED, Cxt>;
|
||
tryCreateSyncProcess(): void;
|
||
}
|