@konplit-services/common 1.0.149 → 1.0.151
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.
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* @module Listener
|
|
8
8
|
*/
|
|
9
9
|
import { NatsConnection, Msg } from "nats";
|
|
10
|
+
import { Status } from "../../helper";
|
|
10
11
|
/**
|
|
11
12
|
* Event Interface
|
|
12
13
|
*
|
|
@@ -18,6 +19,10 @@ interface Event {
|
|
|
18
19
|
subject: string;
|
|
19
20
|
data: any;
|
|
20
21
|
}
|
|
22
|
+
interface ResponseData {
|
|
23
|
+
status: Status.Failed | Status.Success;
|
|
24
|
+
data: any;
|
|
25
|
+
}
|
|
21
26
|
/**
|
|
22
27
|
* Listener Abstract Class
|
|
23
28
|
*
|
|
@@ -29,7 +34,7 @@ interface Event {
|
|
|
29
34
|
*/
|
|
30
35
|
export declare abstract class RequestListener<T extends Event> {
|
|
31
36
|
private nc;
|
|
32
|
-
|
|
37
|
+
protected jc: import("nats").Codec<unknown>;
|
|
33
38
|
/**
|
|
34
39
|
* The subject associated with the event.
|
|
35
40
|
* @abstract
|
|
@@ -46,7 +51,7 @@ export declare abstract class RequestListener<T extends Event> {
|
|
|
46
51
|
* @param {T["data"]} data - The decoded data from the message
|
|
47
52
|
* @param {JsMsg} msg - The raw NATS message
|
|
48
53
|
*/
|
|
49
|
-
abstract onMessageResponse(data: T["data"], msg: Msg):
|
|
54
|
+
abstract onMessageResponse(data: T["data"], msg: Msg): Promise<ResponseData>;
|
|
50
55
|
/**
|
|
51
56
|
* Constructor for the Listener class.
|
|
52
57
|
*
|
|
@@ -45,7 +45,7 @@ class ResponsePublisher {
|
|
|
45
45
|
* @param {number} timeout - The timeout duration to wait for a response
|
|
46
46
|
* @returns {Promise<any>} - Resolves with the reply data from the responding service
|
|
47
47
|
*/
|
|
48
|
-
request(data, timeout =
|
|
48
|
+
request(data, timeout = 10000) {
|
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
50
|
try {
|
|
51
51
|
// Send request and wait for the response
|