test2.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { AcknowledgementService } from "../services/acknowledgement.service";
  2. import { StreamingService } from "./test-streamOBS";
  3. import { MessageSyncrhonizationService } from "../services/synchronization.service";
  4. import { IncomingMessageService } from "../services/incomingMessage.service";
  5. import { map, Observable, take } from "rxjs";
  6. import { LogSetting, MessageLog } from "../dependencies/fisloggingservice/type/datatype";
  7. import { BaseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
  8. const incoming = new IncomingMessageService()
  9. const syncrhonize = new MessageSyncrhonizationService()
  10. const streamService = new StreamingService()
  11. /* -------------- TEST -------------------- */
  12. // change payload into Observable<BaseMessage>
  13. const payload: Observable<BaseMessage> = streamService.stream().pipe(
  14. map(dataSet => ({
  15. header: dataSet.appLogLocId,
  16. data: dataSet
  17. })),
  18. take(5)
  19. );
  20. // TESTING. Please ignore this
  21. payload.pipe(take(3)).subscribe({
  22. next: data => console.log(data),
  23. error: err => console.error(err),
  24. complete: () => console.log(`Streaming Completed`)
  25. })
  26. // Configure Log Setting
  27. let storage: LogSetting = {
  28. storage: "MongoDB",
  29. setting: {
  30. appName: 'Default from client',
  31. appLocName: 'To be generated in client',
  32. logLocName: 'To be generated in client',
  33. },
  34. customSetting: {
  35. server: "localhost:27017",
  36. collection: "logs"
  37. }
  38. }
  39. let dataSet: LogSetting & { incomingObservable: Observable<BaseMessage> } = {
  40. storage: storage.storage,
  41. setting: storage.setting,
  42. customSetting: storage.customSetting,
  43. incomingObservable: payload
  44. }
  45. incoming.init(dataSet)