Browse Source

acknowledgement service (update)

Enzo 1 year ago
parent
commit
a933a94195

+ 9 - 0
interface/acknowledgement.interface.ts

@@ -0,0 +1,9 @@
+import { Observable } from "rxjs";
+import { ResponseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
+import { LogSetting } from "../dependencies/fisloggingservice/type/datatype";
+
+export interface Acknowledgemeent {
+    init(settings: LogSetting): void;
+
+    subscribe(obs: Observable<string>): Observable<ResponseMessage>
+}

+ 48 - 3
services/acknowledgemeent.service.ts

@@ -1,5 +1,50 @@
-export class AcknowledgementService {
-    public acknowledge(){
-        console.log('Hi. My sole existence is to acknowledge You!!!!')
+import { map, Observable, tap } from "rxjs";
+import { ResponseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
+import { FisCreateMessageUtility } from "../dependencies/fisappmessagejsutilty/services/fis.create.message";
+import { LoggingService } from "../dependencies/fisloggingservice/services/logging-service";
+import { LogSetting } from "../dependencies/fisloggingservice/type/datatype";
+import { Acknowledgemeent } from "../interface/acknowledgement.interface";
+
+
+export class AcknowledgementService implements Acknowledgemeent {
+
+    private messageUtil: FisCreateMessageUtility = new FisCreateMessageUtility("FisAppID/Name")
+    private settings: LogSetting = {
+        storage: '',
+        setting: {
+            appId: '',
+            appName: '',
+            logLocName: '',
+            logLocId: '',
+            appLogLocId: '',
+            appLocName: '',
+            appLogId: ''
+        }
+    }
+
+    constructor(private logService?: LoggingService) {
+    }
+
+    // set the data. I dont know what to set yet
+    public async init(settings: LogSetting) {
+        // console.log(settings)
+        this.settings = settings
+        this.logService.init(this.settings)
+        // Error Cannot error properties of undefined (reading 'init')
+    }
+
+    // suppose to call logging service to give an observable type report for every message streamed
+    public subscribe(obs: Observable<any>): Observable<ResponseMessage> {
+        obs.subscribe((data) => {
+            // console.log(data)
+            this.logService.subscribe(data)
+        })
+        let acknowledgementToken = obs.pipe(
+            map(
+                acknowledgement => acknowledgement
+                // acknowledement =>  this.utilMessage.getResponseMessage(Parameters to be discussed)
+            ))
+        this.logService.subscribe(acknowledgementToken) // Only log MessageObservable Type. Cannot log acknowledgement
+        return // return response Message
     }
 }

+ 2 - 0
services/synchronization.service.ts

@@ -1,3 +1,5 @@
+
+
 export class SyncrhonizationService {
     public synchronize(){
         console.log('Hi. My sole existence is to SYNCHRONIZE')

+ 10 - 25
test/test.ts

@@ -1,14 +1,12 @@
-import { Observable, of, take } from "rxjs";
+import { map, Observable, of, take } from "rxjs";
 import * as fs from "fs"
-import { LoggingService } from "../dependencies/fisloggingservice/services/logging-service";
 import { AcknowledgementService } from "../services/acknowledgemeent.service";
 import { StreamingService } from "./stream";
 import { SyncrhonizationService } from "../services/synchronization.service";
 import { LogSetting } from "../dependencies/fisloggingservice/type/datatype";
 const acknowledge = new AcknowledgementService()
 const syncrhonize = new SyncrhonizationService()
-const log = new LoggingService()
-const stream = new StreamingService()
+const streamService = new StreamingService()
 
 // Configure Log Setting
 const storage: LogSetting = {
@@ -20,25 +18,12 @@ const storage: LogSetting = {
     }
 }
 
-console.log(`I am Client 1`)
-acknowledge.acknowledge()
-syncrhonize.synchronize()
+// console.log(`I am Client 1`)
+// syncrhonize.synchronize()
 
-stream.stream().subscribe(data => {
-    // console.log(data)
-    let chainStream = of(data)
-    chainStream.subscribe(
-        // value => console.log(value),
-        error => console.error(error),
-        // () => console.log('Streaming completed')
-    );
-    log.init(storage).then(() => {
-        log.subscribe(data).then(() => {
-             log.filter({ msgId: "44f701a9-8ba7-4e07-bd66-f84db12ae481" }).catch(() => console.log(`Failed to resolve filter`))
-         }).catch(() => console.log(`Failed to resolve stream data`))
-         
-     }).catch(() => console.log(`Failed to resolve init`))
-},
-    error => console.error(error),
-    () => console.log('Streaming completed')
-)
+/* --------------  ACTION -------------------- */
+const payload = streamService.stream()
+
+acknowledge.init(storage).then(() => {
+    acknowledge.subscribe(payload)
+}).catch((e) => console.error(e))