From 0fdc28d797d989f1fd8bac8a4dd33e3d67686722 Mon Sep 17 00:00:00 2001 From: Zheng Chen Date: Mon, 11 Dec 2023 21:06:44 +0800 Subject: [PATCH] fix(protocol): provideChannel (#354) --- apps/general-realtime-data-source/src/index.ts | 8 ++++---- .../2023-12-11-12-58.json | 10 ++++++++++ .../@yuants/protocol/2023-12-11-12-58.json | 10 ++++++++++ libraries/protocol/src/terminal.ts | 16 ++++++++-------- 4 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 common/changes/@yuants/app-general-realtime-data-source/2023-12-11-12-58.json create mode 100644 common/changes/@yuants/protocol/2023-12-11-12-58.json diff --git a/apps/general-realtime-data-source/src/index.ts b/apps/general-realtime-data-source/src/index.ts index f8aac739..c5066ce9 100644 --- a/apps/general-realtime-data-source/src/index.ts +++ b/apps/general-realtime-data-source/src/index.ts @@ -1,4 +1,4 @@ -import { encodePath } from '@yuants/data-model'; +import { encodePath, formatTime } from '@yuants/data-model'; import { IPeriod, Terminal } from '@yuants/protocol'; import Ajv from 'ajv'; import { JSONSchema7 } from 'json-schema'; @@ -99,7 +99,7 @@ const subscribePeriods = (product_id: string, period_in_sec: number) => { mergeMap((mapProductIdToGSRList) => { const gsrList = mapProductIdToGSRList[product_id]; if (!gsrList) { - console.error(new Date(), `Cannot find gsrList for ${product_id}`); + console.error(formatTime(Date.now()), `Cannot find gsrList for ${product_id}`); return EMPTY; } return of(gsrList); @@ -108,7 +108,7 @@ const subscribePeriods = (product_id: string, period_in_sec: number) => { from(gsrList).pipe( map((gsr) => term.consumeChannel( - encodePath('Period', gsr.specific_datasource_id, product_id, period_in_sec), + encodePath('Period', gsr.specific_datasource_id, gsr.specific_product_id, period_in_sec), ), ), toArray(), @@ -158,7 +158,7 @@ const subscribePeriods = (product_id: string, period_in_sec: number) => { }), tap((periods) => { console.info( - new Date(), + formatTime(Date.now()), `SubscribePeriods`, JSON.stringify({ product_id, diff --git a/common/changes/@yuants/app-general-realtime-data-source/2023-12-11-12-58.json b/common/changes/@yuants/app-general-realtime-data-source/2023-12-11-12-58.json new file mode 100644 index 00000000..6e570636 --- /dev/null +++ b/common/changes/@yuants/app-general-realtime-data-source/2023-12-11-12-58.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@yuants/app-general-realtime-data-source", + "comment": "fix provideChannel", + "type": "patch" + } + ], + "packageName": "@yuants/app-general-realtime-data-source" +} \ No newline at end of file diff --git a/common/changes/@yuants/protocol/2023-12-11-12-58.json b/common/changes/@yuants/protocol/2023-12-11-12-58.json new file mode 100644 index 00000000..bbc76f82 --- /dev/null +++ b/common/changes/@yuants/protocol/2023-12-11-12-58.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@yuants/protocol", + "comment": "fix provideChannel", + "type": "patch" + } + ], + "packageName": "@yuants/protocol" +} \ No newline at end of file diff --git a/libraries/protocol/src/terminal.ts b/libraries/protocol/src/terminal.ts index 9b9dc49c..91ac7d60 100644 --- a/libraries/protocol/src/terminal.ts +++ b/libraries/protocol/src/terminal.ts @@ -518,14 +518,14 @@ export class Terminal { from(terminalInfo.subscriptions?.[this.terminalInfo.terminal_id] ?? []).pipe( filter((channel_id) => validate(channel_id)), map((channel_id) => ({ consumer_terminal_id: terminalInfo.terminal_id, channel_id })), - groupBy((x) => x.channel_id), - mergeMap((group) => - group.pipe( - map((x) => x.consumer_terminal_id), - toArray(), - map((arr) => [group.key, arr] as [string, string[]]), - ), - ), + ), + ), + groupBy((x) => x.channel_id), + mergeMap((group) => + group.pipe( + map((x) => x.consumer_terminal_id), + toArray(), + map((arr) => [group.key, arr] as [string, string[]]), ), ), toArray(),