namirasoft-log 1.4.28 → 1.4.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ const NamirasoftLogServerLogGroupTag_1 = require("./NamirasoftLogServerLogGroupT
11
11
  const NamirasoftLogServerValue_1 = require("./NamirasoftLogServerValue");
12
12
  class NamirasoftLogServer extends namirasoft_account_1.NSABaseServer {
13
13
  constructor(base_url, manager, onError) {
14
- super(base_url, `1.4.28`, manager, onError);
14
+ super(base_url, `1.4.29`, manager, onError);
15
15
  this.healthz = new NamirasoftLogServerHealthz_1.NamirasoftLogServerHealthz(this);
16
16
  this.value = new NamirasoftLogServerValue_1.NamirasoftLogServerValue(this);
17
17
  this.log_group_category = new NamirasoftLogServerLogGroupCategory_1.NamirasoftLogServerLogGroupCategory(this);
@@ -2,6 +2,8 @@ import { IStream } from "./IStream";
2
2
  import { Log } from "./Log";
3
3
  import { NamirasoftLogServer } from "./NamirasoftLogServer";
4
4
  export declare class StreamNamirasoftLog implements IStream {
5
+ private queue;
6
+ private isProcessing;
5
7
  server: NamirasoftLogServer;
6
8
  user_id?: string;
7
9
  log_group_id: string;
@@ -13,4 +15,5 @@ export declare class StreamNamirasoftLog implements IStream {
13
15
  messages: string[];
14
16
  post: string[];
15
17
  }): void;
18
+ private processQueue;
16
19
  }
@@ -1,8 +1,19 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.StreamNamirasoftLog = void 0;
4
13
  class StreamNamirasoftLog {
5
14
  constructor(server, log_group_id, getProductID, getWorkspaceID) {
15
+ this.queue = [];
16
+ this.isProcessing = false;
6
17
  this.server = server;
7
18
  this.log_group_id = log_group_id;
8
19
  this.getProductID = getProductID;
@@ -19,10 +30,35 @@ class StreamNamirasoftLog {
19
30
  workspace_id: this.getWorkspaceID(),
20
31
  message
21
32
  };
22
- if (this.user_id)
23
- this.server.log._CreateFor(this.user_id, body);
24
- else
25
- this.server.log.Create(body);
33
+ this.queue.push(() => __awaiter(this, void 0, void 0, function* () {
34
+ if (this.user_id)
35
+ yield this.server.log._CreateFor(this.user_id, body);
36
+ else
37
+ yield this.server.log.Create(body);
38
+ }));
39
+ this.processQueue();
40
+ }
41
+ processQueue() {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ if (this.isProcessing)
44
+ return;
45
+ this.isProcessing = true;
46
+ try {
47
+ while (this.queue.length > 0) {
48
+ const job = this.queue.shift();
49
+ if (job) {
50
+ try {
51
+ yield job();
52
+ }
53
+ catch (err) {
54
+ }
55
+ }
56
+ }
57
+ }
58
+ finally {
59
+ this.isProcessing = false;
60
+ }
61
+ });
26
62
  }
27
63
  }
28
64
  exports.StreamNamirasoftLog = StreamNamirasoftLog;
@@ -1 +1 @@
1
- {"version":3,"file":"StreamNamirasoftLog.js","sourceRoot":"","sources":["../src/StreamNamirasoftLog.ts"],"names":[],"mappings":";;;AAIA,MAAa,mBAAmB;IAO5B,YAAY,MAA2B,EAAE,YAAoB,EAAE,YAAmC,EAAE,cAAqC;QAErI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACzC,CAAC;IACD,KAAK,CAAC,GAAQ,EAAE,QAA+D;QAE3E,IA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7 +8,7 @@
8
8
  "framework": "npm",
9
9
  "application": "package",
10
10
  "private": false,
11
- "version": "1.4.28",
11
+ "version": "1.4.29",
12
12
  "author": "Amir Abolhasani",
13
13
  "license": "MIT",
14
14
  "main": "./dist/index.js",
@@ -17,7 +17,7 @@
17
17
  "build": ""
18
18
  },
19
19
  "dependencies": {
20
- "namirasoft-core": "^1.4.71",
20
+ "namirasoft-core": "^1.4.72",
21
21
  "namirasoft-site": "^1.4.37",
22
22
  "namirasoft-node-cli": "^1.4.7",
23
23
  "namirasoft-account": "^1.4.72"
@@ -39,7 +39,7 @@ export class NamirasoftLogServer extends NSABaseServer
39
39
  log: NamirasoftLogServerLog;
40
40
  constructor(base_url: string, manager: TokenManager, onError: (error: Error) => void)
41
41
  {
42
- super(base_url, `1.4.28`, manager, onError);
42
+ super(base_url, `1.4.29`, manager, onError);
43
43
  this.healthz = new NamirasoftLogServerHealthz(this);
44
44
  this.value = new NamirasoftLogServerValue(this);
45
45
  this.log_group_category = new NamirasoftLogServerLogGroupCategory(this);
@@ -4,6 +4,8 @@ import { NamirasoftLogServer } from "./NamirasoftLogServer";
4
4
 
5
5
  export class StreamNamirasoftLog implements IStream
6
6
  {
7
+ private queue: (() => Promise<void>)[] = [];
8
+ private isProcessing = false;
7
9
  server: NamirasoftLogServer;
8
10
  user_id?: string;
9
11
  log_group_id: string;
@@ -28,9 +30,39 @@ export class StreamNamirasoftLog implements IStream
28
30
  workspace_id: this.getWorkspaceID(),
29
31
  message
30
32
  };
31
- if (this.user_id)
32
- this.server.log._CreateFor(this.user_id, body);
33
- else
34
- this.server.log.Create(body);
33
+ this.queue.push(async () =>
34
+ {
35
+ if (this.user_id)
36
+ await this.server.log._CreateFor(this.user_id, body);
37
+ else
38
+ await this.server.log.Create(body);
39
+ });
40
+ this.processQueue();
41
+ }
42
+ private async processQueue()
43
+ {
44
+ if (this.isProcessing)
45
+ return;
46
+ this.isProcessing = true;
47
+ try
48
+ {
49
+ while (this.queue.length > 0)
50
+ {
51
+ const job = this.queue.shift();
52
+ if (job)
53
+ {
54
+ try
55
+ {
56
+ await job();
57
+ }
58
+ catch (err)
59
+ {
60
+ }
61
+ }
62
+ }
63
+ } finally
64
+ {
65
+ this.isProcessing = false;
66
+ }
35
67
  }
36
68
  }