test2.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. srv: true,
  36. user: "testDB",
  37. password: "h1nt1OyXw6QeUnzS",
  38. server: "cluster0.29sklte.mongodb.net",
  39. collection: "log",
  40. }
  41. }
  42. let dataSet: LogSetting & { incomingObservable: Observable<BaseMessage> } = {
  43. storage: storage.storage,
  44. setting: storage.setting,
  45. customSetting: storage.customSetting,
  46. incomingObservable: payload
  47. }
  48. incoming.init(dataSet)