Bläddra i källkod

new test file (mongoStorage)

Enzo 1 år sedan
förälder
incheckning
41de48326f

+ 1 - 0
package.json

@@ -6,6 +6,7 @@
   "scripts": {
     "build": "tsc -p tsconfig-json",
     "start": "node test/test.js",
+    "start2": "node test/test2.js",
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   "repository": {

+ 1 - 15
services/acknowledgement.service.ts

@@ -10,18 +10,6 @@ import { Acknowledgemeent, AcknowledgementLogSetting } from "../type/acknowledge
 export class AcknowledgementService implements Acknowledgemeent {
 
     private messageUtil: FisCreateMessageUtility = new FisCreateMessageUtility("FisAppID/Name")
-    // private settings1: LogSetting = {
-    //     storage: '',
-    //     setting: {
-    //         appId: '',
-    //         appName: '',
-    //         logLocName: '',
-    //         logLocId: '',
-    //         appLogLocId: '',
-    //         appLocName: '',
-    //         appLogId: ''
-    //     }
-    // }
     private settings2: LogSetting = {
         storage: '',
         setting: {
@@ -40,7 +28,6 @@ export class AcknowledgementService implements Acknowledgemeent {
         this.logService2 = new LoggingService()
     }
 
-    // set the data. I dont know what to set yet
     public async init(settings: AcknowledgementLogSetting) {
         // let logSetting1: LogSetting = {
         //     ...settings,
@@ -65,7 +52,6 @@ export class AcknowledgementService implements Acknowledgemeent {
         this.logService2.init(logSetting2)
     }
 
-    // suppose to call logging service to give an observable type report for every message streamed
     public subscribe(obs: Observable<any>): Observable<ResponseMessage> {
         let acknowledgementToken: Observable<ResponseMessage> = obs.pipe(
             map(
@@ -82,7 +68,7 @@ export class AcknowledgementService implements Acknowledgemeent {
             map(
                 incoming_msg => {
                     let finalResponse:MessageLog = {
-                        appLogLocId: this.settings2.setting.appLogId || "",
+                        appLogLocId: this.settings2.setting.appLogId,
                         appData: {
                             msgId: new Uuid().generateId(),
                             msgLogDateTime: new Date(),

+ 5 - 5
services/incomingMessage.service.ts

@@ -24,11 +24,11 @@ export class IncomingMessageService implements IncomingMessageServiceInterface {
             )
         )
         this.logService.init(logSetting).then(() => {
-            this.logService.subscribe(transformedOBS)
-        }).then(() => {
-            this.acknowledgeService.init(logSetting).then(() => {
-                this.acknowledgeService.subscribe(transformedOBS)
-            }).catch((e) => console.error(e))
+            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))
     }
 }

+ 11 - 3
services/synchronization.service.ts

@@ -1,7 +1,15 @@
+import { Observable } from "rxjs";
+import { MessageSynchronisationServiceInterface, MessageSynchronisationServiceSetting } from "../type/datatype";
 
 
-export class MessageSyncrhonizationService {
-    public synchronize(){
-        console.log('Hi. My sole existence is to SYNCHRONIZE')
+export class MessageSyncrhonizationService implements MessageSynchronisationServiceInterface {
+    
+    public init(settings: MessageSynchronisationServiceSetting): void {
+        console.log(settings)
     }
+    public subscribe(obs: Observable<string>): Observable<any> {
+        console.log(obs)
+        return
+    }
+
 }

+ 0 - 1
test/test.ts

@@ -5,7 +5,6 @@ import { IncomingMessageService } from "../services/incomingMessage.service";
 import { map, Observable } from "rxjs";
 import { LogSetting, MessageLog } from "../dependencies/fisloggingservice/type/datatype";
 import { BaseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
-const acknowledge = new AcknowledgementService()
 const incoming = new IncomingMessageService()
 const syncrhonize = new MessageSyncrhonizationService()
 const streamService = new StreamingService()

+ 51 - 0
test/test2.ts

@@ -0,0 +1,51 @@
+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 { LogSetting, MessageLog } from "../dependencies/fisloggingservice/type/datatype";
+import { BaseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
+const incoming = new IncomingMessageService()
+const syncrhonize = new MessageSyncrhonizationService()
+const streamService = new StreamingService()
+
+/* --------------  TEST -------------------- */
+// change payload into Observable<BaseMessage>
+const payload: Observable<BaseMessage> = streamService.stream().pipe(
+    map(dataSet => ({
+        header: dataSet.appLogLocId,
+        data: dataSet
+    }))
+);
+
+const payload2: Observable<string> = streamService.stream().pipe(
+    map(
+        data => data.appData.msgId
+    )
+)
+// Configure Log Setting
+let storage: LogSetting = {
+    storage: "MongoDB",
+    setting: {
+        appName: 'Default from client',
+        appLocName: 'To be generated in client',
+        logLocName: 'To be generated in client',
+    },
+    customSetting: {
+        server: "localhost:27017",
+        collection: "logs"
+      }
+}
+let dataSet: LogSetting & { incomingObservable: Observable<BaseMessage> } = {
+    storage: storage.storage,
+    setting: storage.setting,
+    customSetting: storage.customSetting,
+    incomingObservable: payload
+}
+
+// incoming.init(dataSet)
+syncrhonize.subscribe(payload2)
+
+// acknowledge.init(storage).then(() => {
+//     acknowledge.subscribe(payload)
+// }).catch((e) => console.error(e))

+ 17 - 0
type/datatype.ts

@@ -11,4 +11,21 @@ type IncomingMessageSetting =  LogSetting & {
  
      // Set default setting
      init(settings: IncomingMessageSetting ): void;
+ }
+
+ //  It can have an incoming and a target logging server. The tags are used to search for specific sets of messages from the logging server. 
+
+export interface MessageSynchronisationServiceSetting {
+    incomingSource:LogSetting & {tags:string[] },   
+    target:LogSetting & {tags:string[] }
+ }
+ 
+ // Acknowledgement Service Class
+ export interface MessageSynchronisationServiceInterface{ 
+ 
+     // Set default setting
+     init(settings: MessageSynchronisationServiceSetting ): void;
+ 
+     // Subscribe to trigger
+     subscribe(obs:Observable<string>): Observable<any>;
  }