Skip to content

Commit

Permalink
fix(protocol): provideChannel (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
zccz14 authored Dec 11, 2023
1 parent 1ee3db8 commit 0fdc28d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
8 changes: 4 additions & 4 deletions apps/general-realtime-data-source/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand All @@ -108,7 +108,7 @@ const subscribePeriods = (product_id: string, period_in_sec: number) => {
from(gsrList).pipe(
map((gsr) =>
term.consumeChannel<IPeriod[]>(
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(),
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@yuants/app-general-realtime-data-source",
"comment": "fix provideChannel",
"type": "patch"
}
],
"packageName": "@yuants/app-general-realtime-data-source"
}
10 changes: 10 additions & 0 deletions common/changes/@yuants/protocol/2023-12-11-12-58.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@yuants/protocol",
"comment": "fix provideChannel",
"type": "patch"
}
],
"packageName": "@yuants/protocol"
}
16 changes: 8 additions & 8 deletions libraries/protocol/src/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 0fdc28d

Please sign in to comment.