소스 검색

minor adjusments

Enzo 1 년 전
부모
커밋
f98ac7b66b
3개의 변경된 파일30개의 추가작업 그리고 26개의 파일을 삭제
  1. 19 9
      services/incomingMessage.service.ts
  2. 0 4
      test/test.ts
  3. 11 13
      test/test2.ts

+ 19 - 9
services/incomingMessage.service.ts

@@ -11,24 +11,34 @@ export class IncomingMessageService implements IncomingMessageServiceInterface {
         this.logService = new LoggingService()
         this.acknowledgeService = new AcknowledgementService()
     }
-    init(settings: LogSetting & { incomingObservable: Observable<BaseMessage>; }): void {
+    public init(settings: LogSetting & { incomingObservable: Observable<BaseMessage>; }): void {
         let logSetting: LogSetting = {
             storage: settings.storage,
             setting: settings.setting,
             customSetting: settings.customSetting
         }
+
         // Transform incoming observables into Observable<MessageLog> to be logged
         let transformedOBS: Observable<any> = settings.incomingObservable.pipe(
-            map(
-                messages => (messages.data)
-            )
+            map(messages => (messages.data))
         )
+
+        /* Trying new promise chaining structure */
         this.logService.init(logSetting).then(() => {
-            this.logService.subscribe(transformedOBS).then(() => {
-                this.acknowledgeService.init(logSetting).then(() => {
-                    this.acknowledgeService.subscribe(transformedOBS)
-                }).catch((e) => console.error(e))
-            }).catch((e) => console.log(e))
+            this.logService.subscribe(transformedOBS)
+        }).catch((e) => console.error(e)).then(() => {
+            this.acknowledgeService.init(logSetting)
+        }).catch((e) => console.error(e)).then(() => {
+            this.acknowledgeService.subscribe(transformedOBS)
         }).catch((e) => console.error(e))
+
+        // this.logService.init(logSetting).then(() => {
+        //     this.logService.subscribe(transformedOBS).then(() => {
+        //         this.acknowledgeService.init(logSetting).then(() => {
+        //             this.acknowledgeService.subscribe(transformedOBS)
+        //         }).catch((e) => console.error(e))
+        //     }).catch((e) => console.log(e))
+        // }).catch((e) => console.error(e))
+
     }
 }

+ 0 - 4
test/test.ts

@@ -35,7 +35,3 @@ let dataSet: LogSetting & { incomingObservable: Observable<BaseMessage> } = {
 }
 
 incoming.init(dataSet)
-
-// acknowledge.init(storage).then(() => {
-//     acknowledge.subscribe(payload)
-// }).catch((e) => console.error(e))

+ 11 - 13
test/test2.ts

@@ -2,7 +2,7 @@ import { AcknowledgementService } from "../services/acknowledgement.service";
 import { StreamingService } from "./test-streamOBS";
 import { MessageSyncrhonizationService } from "../services/synchronization.service";
 import { IncomingMessageService } from "../services/incomingMessage.service";
-import { map, Observable } from "rxjs";
+import { map, Observable, take } from "rxjs";
 import { LogSetting, MessageLog } from "../dependencies/fisloggingservice/type/datatype";
 import { BaseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
 const incoming = new IncomingMessageService()
@@ -15,14 +15,17 @@ const payload: Observable<BaseMessage> = streamService.stream().pipe(
     map(dataSet => ({
         header: dataSet.appLogLocId,
         data: dataSet
-    }))
+    })),
+    take(5)
 );
 
-const payload2: Observable<string> = streamService.stream().pipe(
-    map(
-        data => data.appData.msgId
-    )
-)
+// TESTING. Please ignore this
+payload.pipe(take(3)).subscribe({
+    next: data => console.log(data),
+    error: err => console.error(err),
+    complete: () => console.log(`Streaming Completed`)
+})
+
 // Configure Log Setting
 let storage: LogSetting = {
     storage: "MongoDB",
@@ -43,9 +46,4 @@ let dataSet: LogSetting & { incomingObservable: Observable<BaseMessage> } = {
     incomingObservable: payload
 }
 
-// incoming.init(dataSet)
-syncrhonize.subscribe(payload2)
-
-// acknowledge.init(storage).then(() => {
-//     acknowledge.subscribe(payload)
-// }).catch((e) => console.error(e))
+incoming.init(dataSet)