@jsm-mit/rabbit-motoko-package 0.2.1 → 0.2.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rabbit-task-worker.d.ts","sourceRoot":"","sources":["../src/rabbit-task-worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAW,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAsB,KAAK,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAGlG,qBAAa,gBAAgB;IAUrB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,KAAK;IAXjB,OAAO,CAAC,UAAU,CAA+C;IACjE,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuB;IAEnD,IAAW,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,CAEpC;gBAGW,OAAO,EAAE,MAAM,EACf,mBAAmB,EAAE,MAAM,EAC3B,KAAK,EAAE,iBAAiB;YAItB,YAAY;
|
|
1
|
+
{"version":3,"file":"rabbit-task-worker.d.ts","sourceRoot":"","sources":["../src/rabbit-task-worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAW,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAsB,KAAK,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAGlG,qBAAa,gBAAgB;IAUrB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,KAAK;IAXjB,OAAO,CAAC,UAAU,CAA+C;IACjE,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuB;IAEnD,IAAW,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,CAEpC;gBAGW,OAAO,EAAE,MAAM,EACf,mBAAmB,EAAE,MAAM,EAC3B,KAAK,EAAE,iBAAiB;YAItB,YAAY;IA4BnB,GAAG,IAAI,IAAI;IAWX,IAAI,IAAI,IAAI;CAQtB"}
|
|
@@ -17,36 +17,22 @@ export class RabbitTaskWorker {
|
|
|
17
17
|
if (this.isProcessing)
|
|
18
18
|
return; // Zapobiega nakładaniu się wywołań
|
|
19
19
|
this.isProcessing = true;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// try {
|
|
37
|
-
// await this.claimAndProcessTask(args);
|
|
38
|
-
// } catch (claimErr) {
|
|
39
|
-
// this.pigeon.reportUrgentAsyncSafe('Error at claiming task', BetterJSON.stringify(claimErr));
|
|
40
|
-
// handleErrorProperly(`Error processing task ${taskId}`, claimErr);
|
|
41
|
-
// }
|
|
42
|
-
// }, 10 * 1000);
|
|
43
|
-
// }
|
|
44
|
-
// }
|
|
45
|
-
// } catch (error: any) {
|
|
46
|
-
// logErrorLocallyAndPublishOnErrorSubject("Error in processQueue", error);
|
|
47
|
-
// } finally {
|
|
48
|
-
// this.isProcessing = false;
|
|
49
|
-
// }
|
|
20
|
+
const availableIds = await this.actor.getAvailableTaskIdsAsync(this.channel, false);
|
|
21
|
+
if (!availableIds || availableIds.length === 0) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const timeoutNanos = BigInt(5 * 60 * 1000000000);
|
|
25
|
+
for (const taskId of availableIds) {
|
|
26
|
+
const args = {
|
|
27
|
+
id: taskId,
|
|
28
|
+
timeoutNanos: timeoutNanos
|
|
29
|
+
};
|
|
30
|
+
const task = await this.actor.claimTaskAsync(args, false);
|
|
31
|
+
if (task) {
|
|
32
|
+
this.taskSubject.next(task);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
this.isProcessing = false;
|
|
50
36
|
}
|
|
51
37
|
run() {
|
|
52
38
|
if (this.intervalId)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsm-mit/rabbit-motoko-package",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Wrapper TypeScript package for Rabbit Motoko Canister.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@icp-sdk/core": "^5.2.0",
|
|
30
|
-
"@jsm-mit/pigeon-package": "^0.5.
|
|
30
|
+
"@jsm-mit/pigeon-package": "^0.5.1",
|
|
31
31
|
"@jsm-mit/utils-package": "^0.2.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|