Closed prravda closed 1 year ago
JSON
version
field and consider the compatibilityTypeScript
interface HotDeal {
id: number;
title: string;
link: string;
}
interface PpomppuHotDeal extends HotDeal {}
interface FmKoreaPopularHotDeal extends HotDeal {}
interface FmKoreaGeneralHotDeal extends HotDeal {
seller: string;
productPrice: string;
shippingCharge: string;
category: string;
}
// candidate 0
interface HotDealUpdated_MK1 {
version: number;
timestamp: Date;
listOfHotDeal: (
| PpomppuHotDeal
| FmKoreaPopularHotDeal
| FmKoreaGeneralHotDeal
)[];
}
// candidate_1
interface HotDealUpdated_MK2 {
version: number;
sourceAndType: string;
timestamp: Date;
listOfHotDeal:
| PpomppuHotDeal[]
| FmKoreaPopularHotDeal[]
| FmKoreaGeneralHotDeal[];
}
After considering, I choose the HotDealUpdated_MK2
. The reason is simple. First, I send the list of hot deal various source and various interval. Second, the structure of them are slightly different. And last, If I send the multiple lists of hot deal, the content size of message become larger so I should avoid this scenario.
So, I will design this event like this
interface HotDealUpdated {
version: number;
sourceAndType: string;
timestamp: Date;
listOfHotDeal:
| PpomppuHotDeal[]
| FmKoreaPopularHotDeal[]
| FmKoreaGeneralHotDeal[];
}
TypeScript
enum USER_CAME_FROM {
DISCORD,
}
interface NotificationCreated {
sourceAndType: string;
hotDeal: PpomppuHotDeal | FmKoreaPopularHotDeal | FmKoreaGeneralHotDeal;
userId: string;
destination: USER_CAME_FROM;
}
Goal
HotDealUpdated
kafka
, ormemphis
) said about this?