@yuants/app-virtual-exchange 0.9.4 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/position.js +17 -0
- package/dist/position.js.map +1 -1
- package/dist/quote/__tests__/implementations.test.js +218 -0
- package/dist/quote/__tests__/implementations.test.js.map +1 -0
- package/dist/quote/implementations/v0.js +7 -9
- package/dist/quote/implementations/v0.js.map +1 -1
- package/dist/quote/implementations/v1.js +10 -4
- package/dist/quote/implementations/v1.js.map +1 -1
- package/dist/quote/service.js +103 -30
- package/dist/quote/service.js.map +1 -1
- package/dist/quote/types.js.map +1 -1
- package/dist/quote/upstream/executor.js +98 -0
- package/dist/quote/upstream/executor.js.map +1 -0
- package/dist/quote/upstream/index.js +2 -0
- package/dist/quote/upstream/index.js.map +1 -0
- package/dist/quote/upstream/prefix-matcher.js.map +1 -0
- package/dist/quote/upstream/registry.js +116 -0
- package/dist/quote/upstream/registry.js.map +1 -0
- package/dist/quote/upstream/router.js +119 -0
- package/dist/quote/upstream/router.js.map +1 -0
- package/lib/position.d.ts.map +1 -1
- package/lib/position.js +17 -0
- package/lib/position.js.map +1 -1
- package/lib/quote/__tests__/implementations.test.d.ts +2 -0
- package/lib/quote/__tests__/implementations.test.d.ts.map +1 -0
- package/lib/quote/__tests__/implementations.test.js +220 -0
- package/lib/quote/__tests__/implementations.test.js.map +1 -0
- package/lib/quote/implementations/v0.d.ts.map +1 -1
- package/lib/quote/implementations/v0.js +7 -9
- package/lib/quote/implementations/v0.js.map +1 -1
- package/lib/quote/implementations/v1.d.ts.map +1 -1
- package/lib/quote/implementations/v1.js +10 -4
- package/lib/quote/implementations/v1.js.map +1 -1
- package/lib/quote/service.js +102 -29
- package/lib/quote/service.js.map +1 -1
- package/lib/quote/types.d.ts +18 -0
- package/lib/quote/types.d.ts.map +1 -1
- package/lib/quote/types.js.map +1 -1
- package/lib/quote/upstream/executor.d.ts +8 -0
- package/lib/quote/upstream/executor.d.ts.map +1 -0
- package/lib/quote/upstream/executor.js +102 -0
- package/lib/quote/upstream/executor.js.map +1 -0
- package/lib/quote/upstream/index.d.ts +3 -0
- package/lib/quote/upstream/index.d.ts.map +1 -0
- package/lib/quote/upstream/index.js +6 -0
- package/lib/quote/upstream/index.js.map +1 -0
- package/lib/quote/upstream/prefix-matcher.d.ts.map +1 -0
- package/lib/quote/upstream/prefix-matcher.js.map +1 -0
- package/lib/quote/upstream/registry.d.ts +18 -0
- package/lib/quote/upstream/registry.d.ts.map +1 -0
- package/lib/quote/upstream/registry.js +120 -0
- package/lib/quote/upstream/registry.js.map +1 -0
- package/lib/quote/upstream/router.d.ts +27 -0
- package/lib/quote/upstream/router.d.ts.map +1 -0
- package/lib/quote/upstream/router.js +124 -0
- package/lib/quote/upstream/router.js.map +1 -0
- package/package.json +3 -3
- package/temp/package-deps.json +17 -13
- package/dist/quote/prefix-matcher.js.map +0 -1
- package/dist/quote/request-key.js +0 -20
- package/dist/quote/request-key.js.map +0 -1
- package/dist/quote/upstream-routing.js +0 -300
- package/dist/quote/upstream-routing.js.map +0 -1
- package/lib/quote/prefix-matcher.d.ts.map +0 -1
- package/lib/quote/prefix-matcher.js.map +0 -1
- package/lib/quote/request-key.d.ts +0 -2
- package/lib/quote/request-key.d.ts.map +0 -1
- package/lib/quote/request-key.js +0 -24
- package/lib/quote/request-key.js.map +0 -1
- package/lib/quote/upstream-routing.d.ts +0 -15
- package/lib/quote/upstream-routing.d.ts.map +0 -1
- package/lib/quote/upstream-routing.js +0 -304
- package/lib/quote/upstream-routing.js.map +0 -1
- /package/dist/quote/{prefix-matcher.js → upstream/prefix-matcher.js} +0 -0
- /package/lib/quote/{prefix-matcher.d.ts → upstream/prefix-matcher.d.ts} +0 -0
- /package/lib/quote/{prefix-matcher.js → upstream/prefix-matcher.js} +0 -0
package/lib/quote/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../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AAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;CAClB"}
|
package/lib/quote/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/quote/types.ts"],"names":[],"mappings":"","sourcesContent":["import { IQuote } from '@yuants/data-quote';\n\nexport type IQuoteKey = Exclude<keyof IQuote, 'datasource_id' | 'product_id' | 'updated_at'>;\n\n/**\n * 用于批量更新的数据结构\n * 结构为:\n * product_id -> field_name (keyof IQuote) -> [value: string, updated_at: number]\n * 这样设计的目的是为了减少更新的数据量,同时保留每个字段的更新时间\n *\n * 例如:\n * ```json\n * {\n * \"product_123\": {\n * \"last_price\": [\"100.5\", 1627890123456],\n * \"volume\": [\"1500\", 1627890123456]\n * },\n * \"product_456\": {\n * \"last_price\": [\"200.0\", 1627890123456]\n * }\n * }\n * ```\n * @public\n */\nexport type IQuoteUpdateAction = Record<\n string,\n Partial<Record<IQuoteKey, [value: string, updated_at: number]>>\n>;\nexport interface IQuoteState {\n update: (action: IQuoteUpdateAction) => void;\n dumpAsObject: () => IQuoteUpdateAction;\n getValueTuple: (product_id: string, field: IQuoteKey) => [string, number] | undefined;\n filter: (product_ids: string[], fields: IQuoteKey[], updated_at: number) => IQuoteUpdateAction;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/quote/types.ts"],"names":[],"mappings":"","sourcesContent":["import { IQuote } from '@yuants/data-quote';\nimport { IQuoteServiceMetadata } from '@yuants/exchange';\n\nexport type IQuoteKey = Exclude<keyof IQuote, 'datasource_id' | 'product_id' | 'updated_at'>;\n\n/**\n * 用于批量更新的数据结构\n * 结构为:\n * product_id -> field_name (keyof IQuote) -> [value: string, updated_at: number]\n * 这样设计的目的是为了减少更新的数据量,同时保留每个字段的更新时间\n *\n * 例如:\n * ```json\n * {\n * \"product_123\": {\n * \"last_price\": [\"100.5\", 1627890123456],\n * \"volume\": [\"1500\", 1627890123456]\n * },\n * \"product_456\": {\n * \"last_price\": [\"200.0\", 1627890123456]\n * }\n * }\n * ```\n * @public\n */\nexport type IQuoteUpdateAction = Record<\n string,\n Partial<Record<IQuoteKey, [value: string, updated_at: number]>>\n>;\nexport interface IQuoteState {\n update: (action: IQuoteUpdateAction) => void;\n dumpAsObject: () => IQuoteUpdateAction;\n getValueTuple: (product_id: string, field: IQuoteKey) => [string, number] | undefined;\n filter: (product_ids: string[], fields: IQuoteKey[], updated_at: number) => IQuoteUpdateAction;\n}\n\nexport interface IQuoteProviderInstance {\n terminal_id: string;\n service_id: string;\n}\n\n/**\n * A \"provider group\" is a capability signature of `GetQuotes`.\n * Multiple vendor terminals may provide the same capability; VEX load-balances across instances.\n */\nexport interface IQuoteProviderGroup {\n group_id: string;\n meta: IQuoteServiceMetadata;\n mapTerminalIdToInstance: Map<string, IQuoteProviderInstance>;\n}\n\nexport interface IQuoteRequire {\n product_id: string;\n field: IQuoteKey;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IQuoteUpdateAction as IExchangeQuoteUpdateAction } from '@yuants/exchange';
|
|
2
|
+
import { Terminal } from '@yuants/protocol';
|
|
3
|
+
import { IPlannedRequestWithKey } from './router';
|
|
4
|
+
export interface IGetQuotesExecutor {
|
|
5
|
+
execute: (requests: IPlannedRequestWithKey[]) => Promise<IExchangeQuoteUpdateAction[]>;
|
|
6
|
+
}
|
|
7
|
+
export declare const createGetQuotesExecutor: (terminal: Terminal) => IGetQuotesExecutor;
|
|
8
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/quote/upstream/executor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,IAAI,0BAA0B,EAEjD,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAyFlD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,CAAC,QAAQ,EAAE,sBAAsB,EAAE,KAAK,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAAC;CACxF;AAED,eAAO,MAAM,uBAAuB,aAAc,QAAQ,KAAG,kBAmC5D,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createGetQuotesExecutor = void 0;
|
|
4
|
+
const utils_1 = require("@yuants/utils");
|
|
5
|
+
const rxjs_1 = require("rxjs");
|
|
6
|
+
const createConcurrencyLimiter = (concurrency) => {
|
|
7
|
+
const queue = [];
|
|
8
|
+
let active = 0;
|
|
9
|
+
const next = () => {
|
|
10
|
+
if (active >= concurrency)
|
|
11
|
+
return;
|
|
12
|
+
const task = queue.shift();
|
|
13
|
+
if (!task)
|
|
14
|
+
return;
|
|
15
|
+
active++;
|
|
16
|
+
task();
|
|
17
|
+
};
|
|
18
|
+
return async (fn) => await new Promise((resolve, reject) => {
|
|
19
|
+
queue.push(async () => {
|
|
20
|
+
try {
|
|
21
|
+
resolve(await fn());
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
active--;
|
|
28
|
+
next();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
next();
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const pickInstance = (params) => {
|
|
35
|
+
var _a;
|
|
36
|
+
const { group_id, instances, mapGroupIdToRoundRobinIndex } = params;
|
|
37
|
+
if (instances.length === 0)
|
|
38
|
+
throw (0, utils_1.newError)('VEX_QUOTE_PROVIDER_INSTANCE_EMPTY', { group_id });
|
|
39
|
+
const nextIndex = ((_a = mapGroupIdToRoundRobinIndex.get(group_id)) !== null && _a !== void 0 ? _a : 0) % instances.length;
|
|
40
|
+
mapGroupIdToRoundRobinIndex.set(group_id, nextIndex + 1);
|
|
41
|
+
return instances[nextIndex];
|
|
42
|
+
};
|
|
43
|
+
const requestGetQuotes = async (params) => {
|
|
44
|
+
const { terminal, instance, req } = params;
|
|
45
|
+
const res = await (0, rxjs_1.firstValueFrom)(terminal.client
|
|
46
|
+
.request('GetQuotes', instance.terminal_id, req, instance.service_id)
|
|
47
|
+
.pipe((0, rxjs_1.map)((msg) => msg.res), (0, rxjs_1.filter)((v) => v !== undefined)));
|
|
48
|
+
if (res.code !== 0)
|
|
49
|
+
throw (0, utils_1.newError)('VEX_QUOTE_PROVIDER_ERROR', { instance, res });
|
|
50
|
+
if (res.data === undefined)
|
|
51
|
+
throw (0, utils_1.newError)('VEX_QUOTE_PROVIDER_DATA_MISSING', { instance, res });
|
|
52
|
+
return res.data;
|
|
53
|
+
};
|
|
54
|
+
const runWithProviderGroupConcurrencyLimit1 = async (params) => {
|
|
55
|
+
var _a;
|
|
56
|
+
const { group_id, mapGroupIdToTailPromise, fn } = params;
|
|
57
|
+
const prev = (_a = mapGroupIdToTailPromise.get(group_id)) !== null && _a !== void 0 ? _a : Promise.resolve();
|
|
58
|
+
let resolveCurrent = () => { };
|
|
59
|
+
const current = new Promise((resolve) => {
|
|
60
|
+
resolveCurrent = resolve;
|
|
61
|
+
});
|
|
62
|
+
mapGroupIdToTailPromise.set(group_id, prev.then(() => current));
|
|
63
|
+
await prev;
|
|
64
|
+
try {
|
|
65
|
+
return await fn();
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
resolveCurrent();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const createGetQuotesExecutor = (terminal) => {
|
|
72
|
+
const mapGroupIdToRoundRobinIndex = new Map();
|
|
73
|
+
const mapGroupIdToTailPromise = new Map();
|
|
74
|
+
const limitGetQuotes = createConcurrencyLimiter(32);
|
|
75
|
+
const mapKeyToInFlightGetQuotesPromise = new Map();
|
|
76
|
+
const requestGetQuotesInFlight = (key, planned) => {
|
|
77
|
+
const existing = mapKeyToInFlightGetQuotesPromise.get(key);
|
|
78
|
+
if (existing)
|
|
79
|
+
return existing;
|
|
80
|
+
const promise = limitGetQuotes(() => runWithProviderGroupConcurrencyLimit1({
|
|
81
|
+
group_id: planned.group_id,
|
|
82
|
+
mapGroupIdToTailPromise,
|
|
83
|
+
fn: async () => {
|
|
84
|
+
const instance = pickInstance({
|
|
85
|
+
group_id: planned.group_id,
|
|
86
|
+
instances: planned.instances,
|
|
87
|
+
mapGroupIdToRoundRobinIndex,
|
|
88
|
+
});
|
|
89
|
+
return await requestGetQuotes({ terminal, instance, req: planned.req });
|
|
90
|
+
},
|
|
91
|
+
})).finally(() => {
|
|
92
|
+
mapKeyToInFlightGetQuotesPromise.delete(key);
|
|
93
|
+
});
|
|
94
|
+
mapKeyToInFlightGetQuotesPromise.set(key, promise);
|
|
95
|
+
return promise;
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
execute: async (requests) => await Promise.all(requests.map(async ({ key, planned }) => await requestGetQuotesInFlight(key, planned))),
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
exports.createGetQuotesExecutor = createGetQuotesExecutor;
|
|
102
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/quote/upstream/executor.ts"],"names":[],"mappings":";;;AAKA,yCAAyC;AACzC,+BAAmD;AAMnD,MAAM,wBAAwB,GAAG,CAAC,WAAmB,EAAE,EAAE;IACvD,MAAM,KAAK,GAAsB,EAAE,CAAC;IACpC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,MAAM,IAAI,GAAG,GAAG,EAAE;QAChB,IAAI,MAAM,IAAI,WAAW;YAAE,OAAO;QAClC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,MAAM,EAAE,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G,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,MAAM,wBAAwB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CACvF;KACJ,CAAC;AACJ,CAAC,CAAC;AAnCW,QAAA,uBAAuB,2BAmClC","sourcesContent":["import {\n IQuoteUpdateAction as IExchangeQuoteUpdateAction,\n IQuoteServiceRequestByVEX,\n} from '@yuants/exchange';\nimport { Terminal } from '@yuants/protocol';\nimport { newError } from '@yuants/utils';\nimport { filter, firstValueFrom, map } from 'rxjs';\nimport { IQuoteProviderInstance } from '../types';\nimport { IPlannedRequestWithKey } from './router';\n\ntype IPlannedRequest = IPlannedRequestWithKey['planned'];\n\nconst createConcurrencyLimiter = (concurrency: number) => {\n const queue: Array<() => void> = [];\n let active = 0;\n const next = () => {\n if (active >= concurrency) return;\n const task = queue.shift();\n if (!task) return;\n active++;\n task();\n };\n return async <T>(fn: () => Promise<T>): Promise<T> =>\n await new Promise<T>((resolve, reject) => {\n queue.push(async () => {\n try {\n resolve(await fn());\n } catch (e) {\n reject(e);\n } finally {\n active--;\n next();\n }\n });\n next();\n });\n};\n\nconst pickInstance = (params: {\n group_id: string;\n instances: IQuoteProviderInstance[];\n mapGroupIdToRoundRobinIndex: Map<string, number>;\n}): IQuoteProviderInstance => {\n const { group_id, instances, mapGroupIdToRoundRobinIndex } = params;\n if (instances.length === 0) throw newError('VEX_QUOTE_PROVIDER_INSTANCE_EMPTY', { group_id });\n const nextIndex = (mapGroupIdToRoundRobinIndex.get(group_id) ?? 0) % instances.length;\n mapGroupIdToRoundRobinIndex.set(group_id, nextIndex + 1);\n return instances[nextIndex];\n};\n\nconst requestGetQuotes = async (params: {\n terminal: Terminal;\n instance: IQuoteProviderInstance;\n req: IQuoteServiceRequestByVEX;\n}): Promise<IExchangeQuoteUpdateAction> => {\n const { terminal, instance, req } = params;\n const res = await firstValueFrom(\n terminal.client\n .request<IQuoteServiceRequestByVEX, IExchangeQuoteUpdateAction>(\n 'GetQuotes',\n instance.terminal_id,\n req,\n instance.service_id,\n )\n .pipe(\n map((msg) => msg.res),\n filter((v): v is Exclude<typeof v, undefined> => v !== undefined),\n ),\n );\n if (res.code !== 0) throw newError('VEX_QUOTE_PROVIDER_ERROR', { instance, res });\n if (res.data === undefined) throw newError('VEX_QUOTE_PROVIDER_DATA_MISSING', { instance, res });\n return res.data as any;\n};\n\nconst runWithProviderGroupConcurrencyLimit1 = async <T>(params: {\n group_id: string;\n mapGroupIdToTailPromise: Map<string, Promise<void>>;\n fn: () => Promise<T>;\n}): Promise<T> => {\n const { group_id, mapGroupIdToTailPromise, fn } = params;\n const prev = mapGroupIdToTailPromise.get(group_id) ?? Promise.resolve();\n let resolveCurrent: () => void = () => {};\n const current = new Promise<void>((resolve) => {\n resolveCurrent = resolve;\n });\n mapGroupIdToTailPromise.set(\n group_id,\n prev.then(() => current),\n );\n await prev;\n try {\n return await fn();\n } finally {\n resolveCurrent();\n }\n};\n\nexport interface IGetQuotesExecutor {\n execute: (requests: IPlannedRequestWithKey[]) => Promise<IExchangeQuoteUpdateAction[]>;\n}\n\nexport const createGetQuotesExecutor = (terminal: Terminal): IGetQuotesExecutor => {\n const mapGroupIdToRoundRobinIndex = new Map<string, number>();\n const mapGroupIdToTailPromise = new Map<string, Promise<void>>();\n const limitGetQuotes = createConcurrencyLimiter(32);\n\n const mapKeyToInFlightGetQuotesPromise = new Map<string, Promise<IExchangeQuoteUpdateAction>>();\n const requestGetQuotesInFlight = (key: string, planned: IPlannedRequest) => {\n const existing = mapKeyToInFlightGetQuotesPromise.get(key);\n if (existing) return existing;\n const promise = limitGetQuotes(() =>\n runWithProviderGroupConcurrencyLimit1({\n group_id: planned.group_id,\n mapGroupIdToTailPromise,\n fn: async () => {\n const instance = pickInstance({\n group_id: planned.group_id,\n instances: planned.instances,\n mapGroupIdToRoundRobinIndex,\n });\n return await requestGetQuotes({ terminal, instance, req: planned.req });\n },\n }),\n ).finally(() => {\n mapKeyToInFlightGetQuotesPromise.delete(key);\n });\n mapKeyToInFlightGetQuotesPromise.set(key, promise);\n return promise;\n };\n\n return {\n execute: async (requests) =>\n await Promise.all(\n requests.map(async ({ key, planned }) => await requestGetQuotesInFlight(key, planned)),\n ),\n };\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/quote/upstream/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AACzD,YAAY,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createQuoteProviderRegistry = void 0;
|
|
4
|
+
var registry_1 = require("./registry");
|
|
5
|
+
Object.defineProperty(exports, "createQuoteProviderRegistry", { enumerable: true, get: function () { return registry_1.createQuoteProviderRegistry; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/quote/upstream/index.ts"],"names":[],"mappings":";;;AAAA,uCAAyD;AAAhD,uHAAA,2BAA2B,OAAA","sourcesContent":["export { createQuoteProviderRegistry } from './registry';\nexport type { IQuoteProviderRegistry } from './registry';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefix-matcher.d.ts","sourceRoot":"","sources":["../../../src/quote/upstream/prefix-matcher.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;CAC/B;AAED,eAAO,MAAM,yBAAyB;YACX,MAAM;;yBAMhC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefix-matcher.js","sourceRoot":"","sources":["../../../src/quote/upstream/prefix-matcher.ts"],"names":[],"mappings":";;;AAIO,MAAM,yBAAyB,GAAG,CACvC,OAA4C,EACzB,EAAE;IACrB,MAAM,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC9E,OAAO;QACL,KAAK,EAAE,CAAC,KAAa,EAAO,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;KACpG,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,yBAAyB,6BAOpC","sourcesContent":["export interface IPrefixMatcher<T> {\n match: (value: string) => T[];\n}\n\nexport const createSortedPrefixMatcher = <T>(\n entries: Array<{ prefix: string; value: T }>,\n): IPrefixMatcher<T> => {\n const sorted = [...entries].sort((a, b) => b.prefix.length - a.prefix.length);\n return {\n match: (value: string): T[] => sorted.filter((x) => value.startsWith(x.prefix)).map((x) => x.value),\n };\n};\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Terminal } from '@yuants/protocol';
|
|
2
|
+
import { IQuoteProviderGroup, IQuoteRequire, IQuoteState, IQuoteUpdateAction } from '../types';
|
|
3
|
+
import { IProviderIndices, IPlannedRequestWithKey, QuoteUpstreamPlan } from './router';
|
|
4
|
+
export interface IQuoteProviderRegistry {
|
|
5
|
+
snapshot: () => {
|
|
6
|
+
groups: IQuoteProviderGroup[];
|
|
7
|
+
indices: IProviderIndices;
|
|
8
|
+
};
|
|
9
|
+
planOrThrow: (misses: IQuoteRequire[], updated_at: number) => QuoteUpstreamPlan;
|
|
10
|
+
execute: (requests: IPlannedRequestWithKey[]) => Promise<IQuoteUpdateAction[]>;
|
|
11
|
+
fillQuoteStateFromUpstream: (params: {
|
|
12
|
+
quoteState: IQuoteState;
|
|
13
|
+
cacheMissed: IQuoteRequire[];
|
|
14
|
+
updated_at: number;
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare const createQuoteProviderRegistry: (terminal: Terminal) => IQuoteProviderRegistry;
|
|
18
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/quote/upstream/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAEL,mBAAmB,EAEnB,aAAa,EACb,WAAW,EACX,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,OAAO,EAGL,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM;QAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC;QAAC,OAAO,EAAE,gBAAgB,CAAA;KAAE,CAAC;IAC7E,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,MAAM,KAAK,iBAAiB,CAAC;IAChF,OAAO,EAAE,CAAC,QAAQ,EAAE,sBAAsB,EAAE,KAAK,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC/E,0BAA0B,EAAE,CAAC,MAAM,EAAE;QACnC,UAAU,EAAE,WAAW,CAAC;QACxB,WAAW,EAAE,aAAa,EAAE,CAAC;QAC7B,UAAU,EAAE,MAAM,CAAC;KACpB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AAOD,eAAO,MAAM,2BAA2B,aAAc,QAAQ,KAAG,sBAsKhE,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createQuoteProviderRegistry = void 0;
|
|
4
|
+
const exchange_1 = require("@yuants/exchange");
|
|
5
|
+
const utils_1 = require("@yuants/utils");
|
|
6
|
+
const rxjs_1 = require("rxjs");
|
|
7
|
+
const executor_1 = require("./executor");
|
|
8
|
+
const router_1 = require("./router");
|
|
9
|
+
const normalizeMetadataForGroup = (metadata) => {
|
|
10
|
+
const fields = [...metadata.fields].sort();
|
|
11
|
+
return Object.assign(Object.assign({}, metadata), { fields });
|
|
12
|
+
};
|
|
13
|
+
const createQuoteProviderRegistry = (terminal) => {
|
|
14
|
+
const router = (0, router_1.createQuoteRouter)();
|
|
15
|
+
const executor = (0, executor_1.createGetQuotesExecutor)(terminal);
|
|
16
|
+
const mapGroupIdToGroup = new Map();
|
|
17
|
+
let version = 0;
|
|
18
|
+
let cachedIndices;
|
|
19
|
+
const quoteServiceInfos$ = terminal.terminalInfos$.pipe((0, rxjs_1.map)((infos) => infos.flatMap((info) => {
|
|
20
|
+
var _a;
|
|
21
|
+
return Object.values((_a = info.serviceInfo) !== null && _a !== void 0 ? _a : {})
|
|
22
|
+
.filter((serviceInfo) => serviceInfo.method === 'GetQuotes')
|
|
23
|
+
.map((serviceInfo) => ({ terminal_id: info.terminal_id, serviceInfo }));
|
|
24
|
+
})));
|
|
25
|
+
quoteServiceInfos$
|
|
26
|
+
.pipe((0, utils_1.listWatch)((v) => v.serviceInfo.service_id, (v) => {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
console.info((0, utils_1.formatTime)(Date.now()), `[VEX][Quote]DiscoveringGetQuotesProvider...`, `from terminal ${v.terminal_id}`, `service ${v.serviceInfo.service_id}`, `schema: ${JSON.stringify(v.serviceInfo.schema)}`);
|
|
29
|
+
try {
|
|
30
|
+
const metadata = normalizeMetadataForGroup((0, exchange_1.parseQuoteServiceMetadataFromSchema)(v.serviceInfo.schema));
|
|
31
|
+
const group_id = (0, utils_1.encodePath)(metadata.product_id_prefix, metadata.fields.join(','), (_a = metadata.max_products_per_request) !== null && _a !== void 0 ? _a : '');
|
|
32
|
+
const provider = {
|
|
33
|
+
terminal_id: v.terminal_id,
|
|
34
|
+
service_id: v.serviceInfo.service_id || v.serviceInfo.method,
|
|
35
|
+
};
|
|
36
|
+
const group = (_b = mapGroupIdToGroup.get(group_id)) !== null && _b !== void 0 ? _b : (() => {
|
|
37
|
+
const next = {
|
|
38
|
+
group_id,
|
|
39
|
+
meta: metadata,
|
|
40
|
+
mapTerminalIdToInstance: new Map(),
|
|
41
|
+
};
|
|
42
|
+
mapGroupIdToGroup.set(group_id, next);
|
|
43
|
+
return next;
|
|
44
|
+
})();
|
|
45
|
+
group.mapTerminalIdToInstance.set(provider.terminal_id, provider);
|
|
46
|
+
version++;
|
|
47
|
+
return (0, rxjs_1.of)(void 0).pipe((0, rxjs_1.tap)({
|
|
48
|
+
unsubscribe: () => {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
(_a = mapGroupIdToGroup.get(group_id)) === null || _a === void 0 ? void 0 : _a.mapTerminalIdToInstance.delete(v.terminal_id);
|
|
51
|
+
if (((_b = mapGroupIdToGroup.get(group_id)) === null || _b === void 0 ? void 0 : _b.mapTerminalIdToInstance.size) === 0) {
|
|
52
|
+
mapGroupIdToGroup.delete(group_id);
|
|
53
|
+
}
|
|
54
|
+
version++;
|
|
55
|
+
},
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
catch (_c) {
|
|
59
|
+
console.info((0, utils_1.formatTime)(Date.now()), `[VEX][Quote]IgnoredGetQuotesProvider`, `Ignored GetQuotes provider from terminal ${v.terminal_id}`, `service ${v.serviceInfo.service_id} due to invalid schema.`);
|
|
60
|
+
return rxjs_1.EMPTY;
|
|
61
|
+
}
|
|
62
|
+
}))
|
|
63
|
+
.subscribe();
|
|
64
|
+
const snapshot = () => {
|
|
65
|
+
const groups = Array.from(mapGroupIdToGroup.values());
|
|
66
|
+
if (!cachedIndices || cachedIndices.version !== version) {
|
|
67
|
+
cachedIndices = { version, indices: (0, router_1.buildProviderIndices)(groups) };
|
|
68
|
+
}
|
|
69
|
+
return { groups, indices: cachedIndices.indices };
|
|
70
|
+
};
|
|
71
|
+
const planOrThrow = (misses, updated_at) => {
|
|
72
|
+
const { groups, indices } = snapshot();
|
|
73
|
+
if (groups.length === 0)
|
|
74
|
+
throw (0, utils_1.newError)('VEX_QUOTE_PROVIDER_NOT_FOUND', { method: 'GetQuotes' });
|
|
75
|
+
return router.planOrThrow(misses, indices, updated_at);
|
|
76
|
+
};
|
|
77
|
+
const execute = async (requests) => (await executor.execute(requests));
|
|
78
|
+
const fillQuoteStateFromUpstream = async (params) => {
|
|
79
|
+
const { quoteState, cacheMissed, updated_at } = params;
|
|
80
|
+
if (cacheMissed.length === 0)
|
|
81
|
+
return;
|
|
82
|
+
const { groups } = snapshot();
|
|
83
|
+
console.info((0, utils_1.formatTime)(Date.now()), `[VEX][Quote]UpstreamProviderDiscovery`, ` Discovered ${groups.length} GetQuotes provider groups from terminal infos.`, JSON.stringify(groups));
|
|
84
|
+
const plan = planOrThrow(cacheMissed, updated_at);
|
|
85
|
+
const mapGroupIdToProductIds = new Map();
|
|
86
|
+
for (const { planned } of plan.requests) {
|
|
87
|
+
let productIds = mapGroupIdToProductIds.get(planned.group_id);
|
|
88
|
+
if (!productIds) {
|
|
89
|
+
productIds = new Set();
|
|
90
|
+
mapGroupIdToProductIds.set(planned.group_id, productIds);
|
|
91
|
+
}
|
|
92
|
+
for (const product_id of planned.req.product_ids)
|
|
93
|
+
productIds.add(product_id);
|
|
94
|
+
}
|
|
95
|
+
console.info((0, utils_1.formatTime)(Date.now()), `[VEX][Quote]RouteDispatched`, ` Routed ${cacheMissed.length} missed quotes to ${mapGroupIdToProductIds.size} provider groups.`, JSON.stringify({
|
|
96
|
+
productsByGroupId: [...mapGroupIdToProductIds.entries()].map(([group_id, productIds]) => ({
|
|
97
|
+
group_id,
|
|
98
|
+
product_ids: [...productIds],
|
|
99
|
+
})),
|
|
100
|
+
default_action: plan.defaultAction,
|
|
101
|
+
}));
|
|
102
|
+
if (Object.keys(plan.defaultAction).length > 0) {
|
|
103
|
+
quoteState.update(plan.defaultAction);
|
|
104
|
+
}
|
|
105
|
+
console.info((0, utils_1.formatTime)(Date.now()), `[VEX][Quote]RequestPlanned`, `Planned ${plan.requests.length} upstream GetQuotes requests.`, JSON.stringify(plan.requests.map(({ key, planned }) => ({
|
|
106
|
+
key,
|
|
107
|
+
group_id: planned.group_id,
|
|
108
|
+
product_ids: planned.req.product_ids,
|
|
109
|
+
fields: planned.req.fields,
|
|
110
|
+
}))));
|
|
111
|
+
const actions = await execute(plan.requests);
|
|
112
|
+
console.debug((0, utils_1.formatTime)(Date.now()), `[VEX][Quote]RequestReceived`, `Received ${actions.length} upstream GetQuotes responses.`, JSON.stringify(actions));
|
|
113
|
+
for (const action of actions) {
|
|
114
|
+
quoteState.update(action);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
return { snapshot, planOrThrow, execute, fillQuoteStateFromUpstream };
|
|
118
|
+
};
|
|
119
|
+
exports.createQuoteProviderRegistry = createQuoteProviderRegistry;
|
|
120
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/quote/upstream/registry.ts"],"names":[],"mappings":";;;AAAA,+CAA8F;AAE9F,yCAA4E;AAC5E,+BAA2C;AAS3C,yCAAqD;AACrD,qCAMkB;AAalB,MAAM,yBAAyB,GAAG,CAAC,QAA+B,EAAyB,EAAE;IAC3F,MAAM,MAAM,GAAG,CAAC,GAAI,QAAQ,CAAC,MAAiC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvE,uCAAY,QAAQ,KAAE,MAAM,IAAG;AACjC,CAAC,CAAC;AAEK,MAAM,2BAA2B,GAAG,CAAC,QAAkB,EAA0B,EAAE;IACxF,MAAM,MAAM,GAAG,IAAA,0BAAiB,GAAE,CAAC;IACnC,MAA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seQuoteServiceMetadataFromSchema } from '@yuants/exchange';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath, formatTime, listWatch, newError } from '@yuants/utils';\nimport { EMPTY, map, of, tap } from 'rxjs';\nimport {\n IQuoteKey,\n IQuoteProviderGroup,\n IQuoteProviderInstance,\n IQuoteRequire,\n IQuoteState,\n IQuoteUpdateAction,\n} from '../types';\nimport { createGetQuotesExecutor } from './executor';\nimport {\n buildProviderIndices,\n createQuoteRouter,\n IProviderIndices,\n IPlannedRequestWithKey,\n QuoteUpstreamPlan,\n} from './router';\n\nexport interface IQuoteProviderRegistry {\n snapshot: () => { groups: IQuoteProviderGroup[]; indices: IProviderIndices };\n planOrThrow: (misses: IQuoteRequire[], updated_at: number) => QuoteUpstreamPlan;\n execute: (requests: IPlannedRequestWithKey[]) => Promise<IQuoteUpdateAction[]>;\n fillQuoteStateFromUpstream: (params: {\n quoteState: IQuoteState;\n cacheMissed: IQuoteRequire[];\n updated_at: number;\n }) => Promise<void>;\n}\n\nconst normalizeMetadataForGroup = (metadata: IQuoteServiceMetadata): IQuoteServiceMetadata => {\n const fields = [...(metadata.fields as unknown as IQuoteKey[])].sort();\n return { ...metadata, fields };\n};\n\nexport const createQuoteProviderRegistry = (terminal: Terminal): IQuoteProviderRegistry => {\n const router = createQuoteRouter();\n const executor = createGetQuotesExecutor(terminal);\n\n const mapGroupIdToGroup = new Map<string, IQuoteProviderGroup>();\n let version = 0;\n let cachedIndices: { version: number; indices: IProviderIndices } | undefined;\n\n const quoteServiceInfos$ = terminal.terminalInfos$.pipe(\n map((infos) =>\n infos.flatMap((info) =>\n Object.values(info.serviceInfo ?? {})\n .filter((serviceInfo) => serviceInfo.method === 'GetQuotes')\n .map((serviceInfo) => ({ terminal_id: info.terminal_id, serviceInfo })),\n ),\n ),\n );\n\n quoteServiceInfos$\n .pipe(\n listWatch(\n (v) => v.serviceInfo.service_id,\n (v) => {\n console.info(\n formatTime(Date.now()),\n `[VEX][Quote]DiscoveringGetQuotesProvider...`,\n `from terminal ${v.terminal_id}`,\n `service ${v.serviceInfo.service_id}`,\n `schema: ${JSON.stringify(v.serviceInfo.schema)}`,\n );\n try {\n const metadata = normalizeMetadataForGroup(\n parseQuoteServiceMetadataFromSchema(v.serviceInfo.schema),\n );\n const group_id = encodePath(\n metadata.product_id_prefix,\n (metadata.fields as any[]).join(','),\n metadata.max_products_per_request ?? '',\n );\n const provider: IQuoteProviderInstance = {\n terminal_id: v.terminal_id,\n service_id: v.serviceInfo.service_id || v.serviceInfo.method,\n };\n const group =\n mapGroupIdToGroup.get(group_id) ??\n (() => {\n const next: IQuoteProviderGroup = {\n group_id,\n meta: metadata,\n mapTerminalIdToInstance: new Map<string, IQuoteProviderInstance>(),\n };\n mapGroupIdToGroup.set(group_id, next);\n return next;\n })();\n group.mapTerminalIdToInstance.set(provider.terminal_id, provider);\n version++;\n return of(void 0).pipe(\n tap({\n unsubscribe: () => {\n mapGroupIdToGroup.get(group_id)?.mapTerminalIdToInstance.delete(v.terminal_id);\n if (mapGroupIdToGroup.get(group_id)?.mapTerminalIdToInstance.size === 0) {\n mapGroupIdToGroup.delete(group_id);\n }\n version++;\n },\n }),\n );\n } catch {\n console.info(\n formatTime(Date.now()),\n `[VEX][Quote]IgnoredGetQuotesProvider`,\n `Ignored GetQuotes provider from terminal ${v.terminal_id}`,\n `service ${v.serviceInfo.service_id} due to invalid schema.`,\n );\n return EMPTY;\n }\n },\n ),\n )\n .subscribe();\n\n const snapshot = () => {\n const groups = Array.from(mapGroupIdToGroup.values());\n if (!cachedIndices || cachedIndices.version !== version) {\n cachedIndices = { version, indices: buildProviderIndices(groups) };\n }\n return { groups, indices: cachedIndices.indices };\n };\n\n const planOrThrow = (misses: IQuoteRequire[], updated_at: number): QuoteUpstreamPlan => {\n const { groups, indices } = snapshot();\n if (groups.length === 0) throw newError('VEX_QUOTE_PROVIDER_NOT_FOUND', { method: 'GetQuotes' });\n return router.planOrThrow(misses, indices, updated_at);\n };\n\n const execute = async (requests: IPlannedRequestWithKey[]): Promise<IQuoteUpdateAction[]> =>\n (await executor.execute(requests)) as any;\n\n const fillQuoteStateFromUpstream: IQuoteProviderRegistry['fillQuoteStateFromUpstream'] = async (params) => {\n const { quoteState, cacheMissed, updated_at } = params;\n if (cacheMissed.length === 0) return;\n\n const { groups } = snapshot();\n console.info(\n formatTime(Date.now()),\n `[VEX][Quote]UpstreamProviderDiscovery`,\n ` Discovered ${groups.length} GetQuotes provider groups from terminal infos.`,\n JSON.stringify(groups),\n );\n\n const plan = planOrThrow(cacheMissed, updated_at);\n\n const mapGroupIdToProductIds = new Map<string, Set<string>>();\n for (const { planned } of plan.requests) {\n let productIds = mapGroupIdToProductIds.get(planned.group_id);\n if (!productIds) {\n productIds = new Set<string>();\n mapGroupIdToProductIds.set(planned.group_id, productIds);\n }\n for (const product_id of planned.req.product_ids) productIds.add(product_id);\n }\n console.info(\n formatTime(Date.now()),\n `[VEX][Quote]RouteDispatched`,\n ` Routed ${cacheMissed.length} missed quotes to ${mapGroupIdToProductIds.size} provider groups.`,\n JSON.stringify({\n productsByGroupId: [...mapGroupIdToProductIds.entries()].map(([group_id, productIds]) => ({\n group_id,\n product_ids: [...productIds],\n })),\n default_action: plan.defaultAction,\n }),\n );\n\n if (Object.keys(plan.defaultAction).length > 0) {\n quoteState.update(plan.defaultAction);\n }\n\n console.info(\n formatTime(Date.now()),\n `[VEX][Quote]RequestPlanned`,\n `Planned ${plan.requests.length} upstream GetQuotes requests.`,\n JSON.stringify(\n plan.requests.map(({ key, planned }) => ({\n key,\n group_id: planned.group_id,\n product_ids: planned.req.product_ids,\n fields: planned.req.fields,\n })),\n ),\n );\n\n const actions = await execute(plan.requests);\n console.debug(\n formatTime(Date.now()),\n `[VEX][Quote]RequestReceived`,\n `Received ${actions.length} upstream GetQuotes responses.`,\n JSON.stringify(actions),\n );\n\n for (const action of actions) {\n quoteState.update(action);\n }\n };\n\n return { snapshot, planOrThrow, execute, fillQuoteStateFromUpstream };\n};\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IQuoteServiceRequestByVEX } from '@yuants/exchange';
|
|
2
|
+
import { IPrefixMatcher } from './prefix-matcher';
|
|
3
|
+
import { IQuoteKey, IQuoteProviderGroup, IQuoteProviderInstance, IQuoteRequire, IQuoteUpdateAction } from '../types';
|
|
4
|
+
export declare type IPlannedRequest = {
|
|
5
|
+
group_id: string;
|
|
6
|
+
instances: IQuoteProviderInstance[];
|
|
7
|
+
req: IQuoteServiceRequestByVEX;
|
|
8
|
+
};
|
|
9
|
+
export declare type IPlannedRequestWithKey = {
|
|
10
|
+
key: string;
|
|
11
|
+
planned: IPlannedRequest;
|
|
12
|
+
};
|
|
13
|
+
export declare type QuoteUpstreamPlan = {
|
|
14
|
+
defaultAction: IQuoteUpdateAction;
|
|
15
|
+
requests: IPlannedRequestWithKey[];
|
|
16
|
+
};
|
|
17
|
+
export declare type IProviderIndices = {
|
|
18
|
+
mapGroupIdToGroup: Map<string, IQuoteProviderGroup>;
|
|
19
|
+
prefixMatcher: IPrefixMatcher<string>;
|
|
20
|
+
mapFieldToGroupIds: Map<IQuoteKey, Set<string>>;
|
|
21
|
+
};
|
|
22
|
+
export declare const buildProviderIndices: (groups: IQuoteProviderGroup[]) => IProviderIndices;
|
|
23
|
+
export interface IQuoteRouter {
|
|
24
|
+
planOrThrow: (misses: IQuoteRequire[], indices: IProviderIndices, updated_at: number) => QuoteUpstreamPlan;
|
|
25
|
+
}
|
|
26
|
+
export declare const createQuoteRouter: () => IQuoteRouter;
|
|
27
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/quote/upstream/router.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAA6B,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAsBlB,oBAAY,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,sBAAsB,EAAE,CAAC;IACpC,GAAG,EAAE,yBAAyB,CAAC;CAChC,CAAC;AAEF,oBAAY,sBAAsB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAAC;AAE/E,oBAAY,iBAAiB,GAAG;IAC9B,aAAa,EAAE,kBAAkB,CAAC;IAClC,QAAQ,EAAE,sBAAsB,EAAE,CAAC;CACpC,CAAC;AAEF,oBAAY,gBAAgB,GAAG;IAC7B,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACpD,aAAa,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACtC,kBAAkB,EAAE,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;CACjD,CAAC;AAEF,eAAO,MAAM,oBAAoB,WAAY,mBAAmB,EAAE,KAAG,gBAiBpE,CAAC;AAgCF,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,KAAK,iBAAiB,CAAC;CAC5G;AAED,eAAO,MAAM,iBAAiB,QAAO,YA4DnC,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createQuoteRouter = exports.buildProviderIndices = void 0;
|
|
4
|
+
const util_1 = require("util");
|
|
5
|
+
const utils_1 = require("@yuants/utils");
|
|
6
|
+
const prefix_matcher_1 = require("./prefix-matcher");
|
|
7
|
+
const SEP_BYTE = new Uint8Array([0xff]);
|
|
8
|
+
const encodeStrings = (parts) => {
|
|
9
|
+
const buffers = [];
|
|
10
|
+
for (const part of parts) {
|
|
11
|
+
buffers.push(new util_1.TextEncoder().encode(part));
|
|
12
|
+
buffers.push(SEP_BYTE);
|
|
13
|
+
}
|
|
14
|
+
const totalLength = buffers.reduce((sum, b) => sum + b.length, 0);
|
|
15
|
+
const result = new Uint8Array(totalLength);
|
|
16
|
+
let offset = 0;
|
|
17
|
+
for (const b of buffers) {
|
|
18
|
+
result.set(b, offset);
|
|
19
|
+
offset += b.length;
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
const fnv1a64HexFromStrings = (parts) => (0, utils_1.fnv1a64Hex)(encodeStrings(parts));
|
|
24
|
+
const buildProviderIndices = (groups) => {
|
|
25
|
+
const mapGroupIdToGroup = new Map(groups.map((x) => [x.group_id, x]));
|
|
26
|
+
const prefixMatcher = (0, prefix_matcher_1.createSortedPrefixMatcher)(groups.map((group) => ({ prefix: group.meta.product_id_prefix, value: group.group_id })));
|
|
27
|
+
const mapFieldToGroupIds = new Map();
|
|
28
|
+
for (const group of groups) {
|
|
29
|
+
for (const field of group.meta.fields) {
|
|
30
|
+
let groupIds = mapFieldToGroupIds.get(field);
|
|
31
|
+
if (!groupIds) {
|
|
32
|
+
groupIds = new Set();
|
|
33
|
+
mapFieldToGroupIds.set(field, groupIds);
|
|
34
|
+
}
|
|
35
|
+
groupIds.add(group.group_id);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return { mapGroupIdToGroup, prefixMatcher, mapFieldToGroupIds };
|
|
39
|
+
};
|
|
40
|
+
exports.buildProviderIndices = buildProviderIndices;
|
|
41
|
+
const createRequestKey = (group_id, batchProductIds) => (0, utils_1.encodePath)(group_id, fnv1a64HexFromStrings(batchProductIds));
|
|
42
|
+
const planRequests = (params) => {
|
|
43
|
+
var _a;
|
|
44
|
+
const { productsByGroupId, mapGroupIdToGroup } = params;
|
|
45
|
+
const plannedRequests = [];
|
|
46
|
+
for (const [group_id, productIdSet] of productsByGroupId) {
|
|
47
|
+
const group = mapGroupIdToGroup.get(group_id);
|
|
48
|
+
if (!group)
|
|
49
|
+
continue;
|
|
50
|
+
const sortedProductIds = [...productIdSet].sort();
|
|
51
|
+
const max = (_a = group.meta.max_products_per_request) !== null && _a !== void 0 ? _a : sortedProductIds.length;
|
|
52
|
+
for (let i = 0; i < sortedProductIds.length; i += max) {
|
|
53
|
+
const batchProductIds = sortedProductIds.slice(i, i + max);
|
|
54
|
+
const key = createRequestKey(group_id, batchProductIds);
|
|
55
|
+
plannedRequests.push({
|
|
56
|
+
key,
|
|
57
|
+
planned: {
|
|
58
|
+
group_id,
|
|
59
|
+
instances: Array.from(group.mapTerminalIdToInstance.values()),
|
|
60
|
+
req: { product_ids: batchProductIds, fields: group.meta.fields },
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return plannedRequests;
|
|
66
|
+
};
|
|
67
|
+
const createQuoteRouter = () => ({
|
|
68
|
+
planOrThrow: (misses, indices, updated_at) => {
|
|
69
|
+
const { prefixMatcher, mapFieldToGroupIds, mapGroupIdToGroup } = indices;
|
|
70
|
+
const productsByGroupId = new Map();
|
|
71
|
+
const defaultAction = {};
|
|
72
|
+
const unroutableProducts = new Set();
|
|
73
|
+
const mapProductIdToGroupIds = new Map();
|
|
74
|
+
for (const miss of misses) {
|
|
75
|
+
const { product_id, field } = miss;
|
|
76
|
+
let productGroupIds = mapProductIdToGroupIds.get(product_id);
|
|
77
|
+
if (!productGroupIds) {
|
|
78
|
+
productGroupIds = prefixMatcher.match(product_id);
|
|
79
|
+
mapProductIdToGroupIds.set(product_id, productGroupIds);
|
|
80
|
+
}
|
|
81
|
+
if (productGroupIds.length === 0) {
|
|
82
|
+
unroutableProducts.add(product_id);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const fieldGroupIds = mapFieldToGroupIds.get(field);
|
|
86
|
+
if (!fieldGroupIds) {
|
|
87
|
+
if (!defaultAction[product_id])
|
|
88
|
+
defaultAction[product_id] = {};
|
|
89
|
+
defaultAction[product_id][field] = ['', updated_at];
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
let matched = false;
|
|
93
|
+
for (const group_id of productGroupIds) {
|
|
94
|
+
if (!fieldGroupIds.has(group_id))
|
|
95
|
+
continue;
|
|
96
|
+
matched = true;
|
|
97
|
+
let productIds = productsByGroupId.get(group_id);
|
|
98
|
+
if (!productIds) {
|
|
99
|
+
productIds = new Set();
|
|
100
|
+
productsByGroupId.set(group_id, productIds);
|
|
101
|
+
}
|
|
102
|
+
productIds.add(product_id);
|
|
103
|
+
}
|
|
104
|
+
if (!matched) {
|
|
105
|
+
if (!defaultAction[product_id])
|
|
106
|
+
defaultAction[product_id] = {};
|
|
107
|
+
defaultAction[product_id][field] = ['', updated_at];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (unroutableProducts.size !== 0) {
|
|
111
|
+
throw (0, utils_1.newError)('VEX_QUOTE_PRODUCT_UNROUTABLE', {
|
|
112
|
+
updated_at,
|
|
113
|
+
unroutable_products: [...unroutableProducts].slice(0, 200),
|
|
114
|
+
unroutable_products_total: unroutableProducts.size,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
defaultAction,
|
|
119
|
+
requests: planRequests({ productsByGroupId, mapGroupIdToGroup }),
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
exports.createQuoteRouter = createQuoteRouter;
|
|
124
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../../../src/quote/upstream/router.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AAGnC,yCAAiE;AACjE,qDAA6E;AAS7E,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAExC,MAAM,aAAa,GAAG,CAAC,KAAe,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,gBAAQ,EAAC,8BAA8B,EAAE;gBAC7C,UAAU;gBACV,mBAAmB,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;gBAC1D,yBAAyB,EAAE,kBAAkB,CAAC,IAAI;aACnD,CAAC,CAAC;SACJ;QAED,OAAO;YACL,aAAa;YACb,QAAQ,EAAE,YAAY,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC;SACjE,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AA5DU,QAAA,iBAAiB,qBA4D3B","sourcesContent":["import { TextEncoder } from 'util';\n\nimport { IQuoteServiceRequestByVEX } from '@yuants/exchange';\nimport { encodePath, fnv1a64Hex, newError } from '@yuants/utils';\nimport { createSortedPrefixMatcher, IPrefixMatcher } from './prefix-matcher';\nimport {\n IQuoteKey,\n IQuoteProviderGroup,\n IQuoteProviderInstance,\n IQuoteRequire,\n IQuoteUpdateAction,\n} from '../types';\n\nconst SEP_BYTE = new Uint8Array([0xff]);\n\nconst encodeStrings = (parts: string[]): Uint8Array => {\n const buffers: Uint8Array[] = [];\n for (const part of parts) {\n buffers.push(new TextEncoder().encode(part));\n buffers.push(SEP_BYTE);\n }\n const totalLength = buffers.reduce((sum, b) => sum + b.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const b of buffers) {\n result.set(b, offset);\n offset += b.length;\n }\n return result;\n};\n\nconst fnv1a64HexFromStrings = (parts: string[]): string => fnv1a64Hex(encodeStrings(parts));\n\nexport type IPlannedRequest = {\n group_id: string;\n instances: IQuoteProviderInstance[];\n req: IQuoteServiceRequestByVEX;\n};\n\nexport type IPlannedRequestWithKey = { key: string; planned: IPlannedRequest };\n\nexport type QuoteUpstreamPlan = {\n defaultAction: IQuoteUpdateAction;\n requests: IPlannedRequestWithKey[];\n};\n\nexport type IProviderIndices = {\n mapGroupIdToGroup: Map<string, IQuoteProviderGroup>;\n prefixMatcher: IPrefixMatcher<string>;\n mapFieldToGroupIds: Map<IQuoteKey, Set<string>>;\n};\n\nexport const buildProviderIndices = (groups: IQuoteProviderGroup[]): IProviderIndices => {\n const mapGroupIdToGroup = new Map(groups.map((x) => [x.group_id, x] as const));\n const prefixMatcher = createSortedPrefixMatcher(\n groups.map((group) => ({ prefix: group.meta.product_id_prefix, value: group.group_id })),\n );\n const mapFieldToGroupIds = new Map<IQuoteKey, Set<string>>();\n for (const group of groups) {\n for (const field of group.meta.fields as IQuoteKey[]) {\n let groupIds = mapFieldToGroupIds.get(field);\n if (!groupIds) {\n groupIds = new Set<string>();\n mapFieldToGroupIds.set(field, groupIds);\n }\n groupIds.add(group.group_id);\n }\n }\n return { mapGroupIdToGroup, prefixMatcher, mapFieldToGroupIds };\n};\n\nconst createRequestKey = (group_id: string, batchProductIds: string[]) =>\n encodePath(group_id, fnv1a64HexFromStrings(batchProductIds));\n\nconst planRequests = (params: {\n productsByGroupId: Map<string, Set<string>>;\n mapGroupIdToGroup: Map<string, IQuoteProviderGroup>;\n}): IPlannedRequestWithKey[] => {\n const { productsByGroupId, mapGroupIdToGroup } = params;\n const plannedRequests: IPlannedRequestWithKey[] = [];\n for (const [group_id, productIdSet] of productsByGroupId) {\n const group = mapGroupIdToGroup.get(group_id);\n if (!group) continue;\n const sortedProductIds = [...productIdSet].sort();\n const max = group.meta.max_products_per_request ?? sortedProductIds.length;\n for (let i = 0; i < sortedProductIds.length; i += max) {\n const batchProductIds = sortedProductIds.slice(i, i + max);\n const key = createRequestKey(group_id, batchProductIds);\n plannedRequests.push({\n key,\n planned: {\n group_id,\n instances: Array.from(group.mapTerminalIdToInstance.values()),\n req: { product_ids: batchProductIds, fields: group.meta.fields as any },\n },\n });\n }\n }\n return plannedRequests;\n};\n\nexport interface IQuoteRouter {\n planOrThrow: (misses: IQuoteRequire[], indices: IProviderIndices, updated_at: number) => QuoteUpstreamPlan;\n}\n\nexport const createQuoteRouter = (): IQuoteRouter => ({\n planOrThrow: (misses, indices, updated_at) => {\n const { prefixMatcher, mapFieldToGroupIds, mapGroupIdToGroup } = indices;\n const productsByGroupId = new Map<string, Set<string>>();\n const defaultAction: IQuoteUpdateAction = {};\n const unroutableProducts = new Set<string>();\n\n const mapProductIdToGroupIds = new Map<string, string[]>();\n\n for (const miss of misses) {\n const { product_id, field } = miss;\n\n let productGroupIds = mapProductIdToGroupIds.get(product_id);\n if (!productGroupIds) {\n productGroupIds = prefixMatcher.match(product_id);\n mapProductIdToGroupIds.set(product_id, productGroupIds);\n }\n if (productGroupIds.length === 0) {\n unroutableProducts.add(product_id);\n continue;\n }\n\n const fieldGroupIds = mapFieldToGroupIds.get(field);\n if (!fieldGroupIds) {\n if (!defaultAction[product_id]) defaultAction[product_id] = {};\n defaultAction[product_id]![field] = ['', updated_at];\n continue;\n }\n\n let matched = false;\n for (const group_id of productGroupIds) {\n if (!fieldGroupIds.has(group_id)) continue;\n matched = true;\n let productIds = productsByGroupId.get(group_id);\n if (!productIds) {\n productIds = new Set<string>();\n productsByGroupId.set(group_id, productIds);\n }\n productIds.add(product_id);\n }\n\n if (!matched) {\n if (!defaultAction[product_id]) defaultAction[product_id] = {};\n defaultAction[product_id]![field] = ['', updated_at];\n }\n }\n\n if (unroutableProducts.size !== 0) {\n throw newError('VEX_QUOTE_PRODUCT_UNROUTABLE', {\n updated_at,\n unroutable_products: [...unroutableProducts].slice(0, 200),\n unroutable_products_total: unroutableProducts.size,\n });\n }\n\n return {\n defaultAction,\n requests: planRequests({ productsByGroupId, mapGroupIdToGroup }),\n };\n },\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuants/app-virtual-exchange",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"@yuants/protocol": "0.53.3",
|
|
12
12
|
"@yuants/utils": "0.15.0",
|
|
13
13
|
"@yuants/data-product": "0.5.1",
|
|
14
|
-
"@yuants/data-account": "0.
|
|
14
|
+
"@yuants/data-account": "0.11.0",
|
|
15
15
|
"@yuants/data-order": "0.7.1",
|
|
16
16
|
"@yuants/data-quote": "0.3.1",
|
|
17
17
|
"@yuants/secret": "0.4.1",
|
|
18
18
|
"@yuants/sql": "0.9.31",
|
|
19
|
-
"@yuants/exchange": "0.
|
|
19
|
+
"@yuants/exchange": "0.7.0",
|
|
20
20
|
"@yuants/cache": "0.3.4",
|
|
21
21
|
"rxjs": "~7.5.6",
|
|
22
22
|
"ajv": "~8.12.0"
|