woonplan-packages-redishelper 1.0.37 → 1.0.41
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.
- package/dist/getters.d.ts +1 -1
- package/dist/getters.js +12 -3
- package/dist/index.js +1 -1
- package/getters.ts +13 -3
- package/package.json +1 -1
package/dist/getters.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Redis } from "ioredis";
|
|
2
2
|
declare const getOrRequestKey: (client: Redis, key: string, service: string) => Promise<unknown>;
|
|
3
|
-
declare const subscribeToMessageResponse: (client: Redis, messageid: string) =>
|
|
3
|
+
declare const subscribeToMessageResponse: (client: Redis, messageid: string, timeout: number) => void;
|
|
4
4
|
declare const requestAndWaitForList: (client: Redis, service: string, listname: string, listsubject: string, props: {} | undefined, {}: {}) => Promise<unknown>;
|
|
5
5
|
export { getOrRequestKey, requestAndWaitForList, subscribeToMessageResponse };
|
package/dist/getters.js
CHANGED
|
@@ -23,7 +23,7 @@ var requestAndWaitForKey = function (client, key, service) { return new Promise(
|
|
|
23
23
|
client.xadd("keyRequestedFrom".concat(service, "Service"), '*', 'key', key)
|
|
24
24
|
.then(function (messageid) {
|
|
25
25
|
// create a key to listen to, the key contains the message we just created;
|
|
26
|
-
return subscribeToMessageResponse(client, messageid);
|
|
26
|
+
return subscribeToMessageResponse(client, messageid, 250);
|
|
27
27
|
}).then(function () {
|
|
28
28
|
// we are subscribed
|
|
29
29
|
// setting up a one time event listener
|
|
@@ -36,9 +36,18 @@ var requestAndWaitForKey = function (client, key, service) { return new Promise(
|
|
|
36
36
|
resolve(null);
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
-
}).catch(function () {
|
|
39
|
+
}).catch(function (e) {
|
|
40
|
+
console.log(e);
|
|
41
|
+
resolve(null);
|
|
42
|
+
});
|
|
40
43
|
}); };
|
|
41
|
-
var subscribeToMessageResponse = function (client, messageid
|
|
44
|
+
var subscribeToMessageResponse = function (client, messageid, timeout) {
|
|
45
|
+
setTimeout(function () {
|
|
46
|
+
if (client.status != "end")
|
|
47
|
+
console.log("sub ".concat(messageid, " timedout"));
|
|
48
|
+
}, timeout);
|
|
49
|
+
client.subscribe((0, utils_1.getMessageReponseKey)(messageid));
|
|
50
|
+
};
|
|
42
51
|
exports.subscribeToMessageResponse = subscribeToMessageResponse;
|
|
43
52
|
var requestAndWaitForList = function (client, service, listname, listsubject, props, _a) {
|
|
44
53
|
if (props === void 0) { props = {}; }
|
package/dist/index.js
CHANGED
|
@@ -43,7 +43,7 @@ var listenForMessage = function (client, groupname, channelname, consumername, c
|
|
|
43
43
|
return;
|
|
44
44
|
messagedata[key] = keysandvalues[n + 1];
|
|
45
45
|
});
|
|
46
|
-
callback(messagedata, id).catch(function (error) {
|
|
46
|
+
callback(messagedata, id, client).catch(function (error) {
|
|
47
47
|
console.log(error);
|
|
48
48
|
// in case somebody was subscribed to the response;
|
|
49
49
|
(0, setters_1.publishMessageResponse)(client, id, '');
|
package/getters.ts
CHANGED
|
@@ -32,7 +32,7 @@ const requestAndWaitForKey = (
|
|
|
32
32
|
.then(
|
|
33
33
|
(messageid:string) => {
|
|
34
34
|
// create a key to listen to, the key contains the message we just created;
|
|
35
|
-
return subscribeToMessageResponse( client, messageid )
|
|
35
|
+
return subscribeToMessageResponse( client, messageid, 250 )
|
|
36
36
|
}
|
|
37
37
|
).then(
|
|
38
38
|
() => {
|
|
@@ -51,11 +51,21 @@ const requestAndWaitForKey = (
|
|
|
51
51
|
})
|
|
52
52
|
}
|
|
53
53
|
).catch(
|
|
54
|
-
() =>
|
|
54
|
+
(e) => {
|
|
55
|
+
console.log( e )
|
|
56
|
+
resolve( null )
|
|
57
|
+
}
|
|
55
58
|
)
|
|
56
59
|
})
|
|
57
60
|
|
|
58
|
-
const subscribeToMessageResponse = ( client:Redis, messageid:string ) =>
|
|
61
|
+
const subscribeToMessageResponse = ( client:Redis, messageid:string, timeout:number ) => {
|
|
62
|
+
setTimeout( () => {
|
|
63
|
+
if( client.status != "end" )
|
|
64
|
+
console.log( `sub ${messageid} timedout`)
|
|
65
|
+
|
|
66
|
+
}, timeout )
|
|
67
|
+
client.subscribe( getMessageReponseKey( messageid ) )
|
|
68
|
+
}
|
|
59
69
|
|
|
60
70
|
|
|
61
71
|
const requestAndWaitForList = (
|