增加了cluster定义

This commit is contained in:
Xu Chang 2023-12-02 15:37:03 +08:00
parent f359b69956
commit 2db0117d56
10 changed files with 43 additions and 23 deletions

View File

@ -1,8 +1,9 @@
/// <reference types="node" /> /// <reference types="node" />
import { EntityDict, RowStore, OperateOption, OperationResult, SelectOption, Context, TxnOption, OpRecord, AggregationResult } from "../types"; import { EntityDict, RowStore, OperateOption, OperationResult, SelectOption, Context, TxnOption, OpRecord, AggregationResult, ClusterInfo } from "../types";
import { IncomingHttpHeaders } from "http"; import { IncomingHttpHeaders } from "http";
export declare abstract class AsyncContext<ED extends EntityDict> implements Context { export declare abstract class AsyncContext<ED extends EntityDict> implements Context {
rowStore: AsyncRowStore<ED, this>; rowStore: AsyncRowStore<ED, this>;
clusterInfo?: ClusterInfo;
private uuid?; private uuid?;
opRecords: OpRecord<ED>[]; opRecords: OpRecord<ED>[];
private scene?; private scene?;
@ -16,7 +17,7 @@ export declare abstract class AsyncContext<ED extends EntityDict> implements Con
* *
*/ */
abstract refineOpRecords(): Promise<void>; abstract refineOpRecords(): Promise<void>;
constructor(store: AsyncRowStore<ED, AsyncContext<ED>>, headers?: IncomingHttpHeaders); constructor(store: AsyncRowStore<ED, AsyncContext<ED>>, headers?: IncomingHttpHeaders, clusterInfo?: ClusterInfo);
setHeaders(headers: IncomingHttpHeaders): void; setHeaders(headers: IncomingHttpHeaders): void;
getHeader(key: string): string | string[] | undefined; getHeader(key: string): string | string[] | undefined;
getScene(): string | undefined; getScene(): string | undefined;

View File

@ -5,14 +5,16 @@ const tslib_1 = require("tslib");
const assert_1 = tslib_1.__importDefault(require("assert")); const assert_1 = tslib_1.__importDefault(require("assert"));
class AsyncContext { class AsyncContext {
rowStore; rowStore;
clusterInfo;
uuid; uuid;
opRecords; opRecords;
scene; scene;
headers; headers;
message; message;
events; events;
constructor(store, headers) { constructor(store, headers, clusterInfo) {
this.rowStore = store; this.rowStore = store;
this.clusterInfo = clusterInfo;
this.opRecords = []; this.opRecords = [];
this.events = { this.events = {
commit: [], commit: [],

5
lib/types/Cluster.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
export type ClusterInfo = {
usingCluster: boolean;
instanceId?: number;
instanceCount?: number;
};

2
lib/types/Cluster.js Normal file
View File

@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@ -23,3 +23,4 @@ export * from './Style';
export * from './EntityDesc'; export * from './EntityDesc';
export * from './Environment'; export * from './Environment';
export * from './Locale'; export * from './Locale';
export * from './Cluster';

View File

@ -26,3 +26,4 @@ tslib_1.__exportStar(require("./Style"), exports);
tslib_1.__exportStar(require("./EntityDesc"), exports); tslib_1.__exportStar(require("./EntityDesc"), exports);
tslib_1.__exportStar(require("./Environment"), exports); tslib_1.__exportStar(require("./Environment"), exports);
tslib_1.__exportStar(require("./Locale"), exports); tslib_1.__exportStar(require("./Locale"), exports);
tslib_1.__exportStar(require("./Cluster"), exports);

View File

@ -1,23 +1,23 @@
import chalk from 'chalk'; import chalk from 'chalk';
import spawn from 'cross-spawn'; import spawn from 'cross-spawn';
import { resolve } from 'path';
// ts-node scripts/build-app-domain & npm link ./app-domain // ts-node scripts/build-app-domain & npm link ./app-domain
console.log(`${chalk.greenBright(`build base-app-domain`)}`); console.log(`${chalk.greenBright(`build base-app-domain`)}`);
const result = spawn.sync( const result = spawn.sync(
'ts-node', 'ts-node',
[require.resolve('./buildBaseEntityDict.ts')], [resolve(process.cwd(), 'scripts', 'buildBaseEntityDict.ts')],
{ {
stdio: 'inherit', stdio: 'inherit',
shell: true, shell: true,
}
);
// const result2 = spawn.sync('npm -v', [], { stdio: 'inherit', shell: true });
if (result.status === 0) {
console.log(`${chalk.greenBright(`build 执行完成`)}`);
} else {
Error(`${chalk.redBright(`build 执行失败`)}`);
process.exit(1);
} }
);
// const result2 = spawn.sync('npm -v', [], { stdio: 'inherit', shell: true });
if (result.status === 0) {
console.log(`${chalk.greenBright(`build 执行完成`)}`);
} else {
Error(`${chalk.redBright(`build 执行失败`)}`);
process.exit(1);
}

View File

@ -1,10 +1,11 @@
import { EntityDict, RowStore, OperateOption, OperationResult, SelectOption, Context, TxnOption, OpRecord, AggregationResult } from "../types"; import { EntityDict, RowStore, OperateOption, OperationResult, SelectOption, Context, TxnOption, OpRecord, AggregationResult, ClusterInfo } from "../types";
import assert from "assert"; import assert from "assert";
import { IncomingHttpHeaders } from "http"; import { IncomingHttpHeaders } from "http";
export abstract class AsyncContext<ED extends EntityDict> implements Context { export abstract class AsyncContext<ED extends EntityDict> implements Context {
rowStore: AsyncRowStore<ED, this>; rowStore: AsyncRowStore<ED, this>;
clusterInfo?: ClusterInfo;
private uuid?: string; private uuid?: string;
opRecords: OpRecord<ED>[]; opRecords: OpRecord<ED>[];
private scene?: string; private scene?: string;
@ -20,8 +21,9 @@ export abstract class AsyncContext<ED extends EntityDict> implements Context {
*/ */
abstract refineOpRecords(): Promise<void>; abstract refineOpRecords(): Promise<void>;
constructor(store: AsyncRowStore<ED, AsyncContext<ED>>, headers?: IncomingHttpHeaders) { constructor(store: AsyncRowStore<ED, AsyncContext<ED>>, headers?: IncomingHttpHeaders, clusterInfo?: ClusterInfo) {
this.rowStore = store; this.rowStore = store;
this.clusterInfo = clusterInfo;
this.opRecords = []; this.opRecords = [];
this.events = { this.events = {
commit: [], commit: [],

5
src/types/Cluster.ts Normal file
View File

@ -0,0 +1,5 @@
export type ClusterInfo = {
usingCluster: boolean;
instanceId?: number;
instanceCount?: number;
};

View File

@ -23,3 +23,4 @@ export * from './Style';
export * from './EntityDesc'; export * from './EntityDesc';
export * from './Environment'; export * from './Environment';
export * from './Locale'; export * from './Locale';
export * from './Cluster';