woonplan-packages-redishelper 1.0.64 → 1.0.68

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/data.ts CHANGED
@@ -50,9 +50,6 @@ const requestAndWaitForKey = (
50
50
 
51
51
  const subscribeToMessageResponse = ( client:Redis, messageid:string ) => client.subscribe( getMessageReponseKey( messageid ) )
52
52
 
53
- const publishMessageResponse = ( client:Redis, messageid:string, message:string ) => client.publish( getMessageReponseKey( messageid ), message )
54
-
55
-
56
53
  const requestAndWaitForList = (
57
54
  client:Redis,
58
55
  service:string,
@@ -74,4 +71,4 @@ const requestAndWaitForList = (
74
71
  const capitalizeFirstLetter = (string:string) => string.charAt(0).toUpperCase() + string.slice(1)
75
72
 
76
73
 
77
- export { getOrRequestKey, requestAndWaitForList, publishMessageResponse, subscribeToMessageResponse }
74
+ export { getOrRequestKey, requestAndWaitForList, subscribeToMessageResponse }
package/dist/data.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Redis } from "ioredis";
2
2
  declare const getOrRequestKey: (client: Redis, key: string, service: string) => Promise<unknown>;
3
3
  declare const subscribeToMessageResponse: (client: Redis, messageid: string) => Promise<number>;
4
- declare const publishMessageResponse: (client: Redis, messageid: string, message: string) => Promise<number>;
5
4
  declare const requestAndWaitForList: (client: Redis, service: string, listname: string, listsubject: string, props: {} | undefined, {}: {}) => Promise<unknown>;
6
- export { getOrRequestKey, requestAndWaitForList, publishMessageResponse, subscribeToMessageResponse };
5
+ export { getOrRequestKey, requestAndWaitForList, subscribeToMessageResponse };
package/dist/data.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.subscribeToMessageResponse = exports.publishMessageResponse = exports.requestAndWaitForList = exports.getOrRequestKey = void 0;
3
+ exports.subscribeToMessageResponse = exports.requestAndWaitForList = exports.getOrRequestKey = void 0;
4
4
  var utils_1 = require("./utils");
5
5
  var setters_1 = require("./setters");
6
6
  var getOrRequestKey = function (client, key, service) { return new Promise(function (resolve, reject) {
@@ -33,8 +33,6 @@ var requestAndWaitForKey = function (client, key, service) { return new Promise(
33
33
  }); };
34
34
  var subscribeToMessageResponse = function (client, messageid) { return client.subscribe((0, utils_1.getMessageReponseKey)(messageid)); };
35
35
  exports.subscribeToMessageResponse = subscribeToMessageResponse;
36
- var publishMessageResponse = function (client, messageid, message) { return client.publish((0, utils_1.getMessageReponseKey)(messageid), message); };
37
- exports.publishMessageResponse = publishMessageResponse;
38
36
  var requestAndWaitForList = function (client, service, listname, listsubject, props, _a) {
39
37
  if (props === void 0) { props = {}; }
40
38
  return new Promise(function (resolve) {
package/dist/getters.js CHANGED
@@ -4,7 +4,7 @@ exports.subscribeToMessageResponse = exports.requestAndWaitForList = exports.get
4
4
  var utils_1 = require("./utils");
5
5
  var memdb_1 = require("./memdb");
6
6
  var uuid_1 = require("uuid");
7
- var timeout = 250;
7
+ var timeout = 1500;
8
8
  var getOrRequestData = function (config, request, service, data) {
9
9
  if (data === void 0) { data = {}; }
10
10
  return new Promise(function (resolve, reject) {
@@ -26,7 +26,7 @@ var requestAndWaitForData = function (getterclient, config, request, service, da
26
26
  var listenerclient = (0, memdb_1.getRedisClient)(config);
27
27
  subscribeToMessageResponse(listenerclient, messageid).
28
28
  then(function () {
29
- console.log("subscribed to ".concat(messageid, " at ").concat(new Date().toISOString()));
29
+ //console.log( `subscribed to ${messageid} at ${new Date().toISOString()}` )
30
30
  // we are subscribed
31
31
  // send out the request
32
32
  getterclient.xadd((0, utils_1.getKeyRequestedChannelName)(service), '*', 'request', request, 'messageid', messageid, 'data', JSON.stringify(data))
package/dist/index.js CHANGED
@@ -111,8 +111,6 @@ var listenForMessage = function (client, groupname, channelname, consumername, c
111
111
  client.xack(channelname, groupname, id).then(function () {
112
112
  console.log(id + ' acknowledged');
113
113
  });
114
- // in case somebody was subscribed to the response;
115
- (0, setters_1.publishMessageResponse)(client, id, '');
116
114
  // relisten
117
115
  listenForMessage(client, groupname, channelname, consumername, callback);
118
116
  });
package/dist/setters.js CHANGED
@@ -12,13 +12,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.sendMessageToStream = exports.publishMessageResponse = void 0;
13
13
  var utils_1 = require("./utils");
14
14
  var publishMessageResponse = function (client, messageid, message) {
15
- console.log("publishing to ".concat(messageid, " at ").concat(new Date().toISOString()));
15
+ //console.log( `publishing to ${messageid} at ${new Date().toISOString()}` )
16
16
  return client.publish((0, utils_1.getMessageReponseKey)(messageid), message);
17
17
  };
18
18
  exports.publishMessageResponse = publishMessageResponse;
19
19
  var sendMessageToStream = function (client, channelname, message) {
20
20
  var arrayOfKeysAndValues = (0, utils_1.redisMessageToArrayOfKeysAndValues)(message).reduce(utils_1.reduceArraysToArray, []);
21
- console.log('sendings message', channelname);
21
+ console.log('sending message', channelname);
22
22
  return client.xadd.apply(client, __spreadArray([channelname, '*'], arrayOfKeysAndValues, false));
23
23
  };
24
24
  exports.sendMessageToStream = sendMessageToStream;
package/getters.ts CHANGED
@@ -4,7 +4,7 @@ import { RedisConfig, Struct } from "./types"
4
4
  import { getRedisClient } from "./memdb"
5
5
  import { v4 as uuidv4 } from 'uuid';
6
6
 
7
- const timeout = 250;
7
+ const timeout = 1500;
8
8
 
9
9
  const getOrRequestData = ( config:RedisConfig, request:string, service:string, data:Struct={} ) => new Promise((resolve, reject) => {
10
10
  const getterclient = getRedisClient( config )
@@ -36,7 +36,7 @@ const requestAndWaitForData = (
36
36
  subscribeToMessageResponse( listenerclient, messageid ).
37
37
  then(
38
38
  () => {
39
- console.log( `subscribed to ${messageid} at ${new Date().toISOString()}` )
39
+ //console.log( `subscribed to ${messageid} at ${new Date().toISOString()}` )
40
40
  // we are subscribed
41
41
  // send out the request
42
42
  getterclient.xadd( getKeyRequestedChannelName( service ), '*', 'request', request, 'messageid', messageid, 'data', JSON.stringify( data ) )
package/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Redis } from "ioredis"
2
- import { RedisConfig, RedisMessage, Struct } from "./types"
2
+ import { RedisConfig, RedisMessage } from "./types"
3
3
  import { sendMessageToStream, publishMessageResponse } from "./setters"
4
4
  import { getOrRequestData, subscribeToMessageResponse, requestAndWaitForList } from "./getters"
5
5
  import { getRedisClient } from "./memdb"
@@ -137,10 +137,6 @@ const listenForMessage = ( client:Redis, groupname:string, channelname:string, c
137
137
  client.xack( channelname, groupname, id ).then( () => {
138
138
  console.log( id + ' acknowledged')
139
139
  })
140
-
141
- // in case somebody was subscribed to the response;
142
- publishMessageResponse( client, id, '' );
143
-
144
140
  // relisten
145
141
  listenForMessage( client, groupname, channelname, consumername, callback );
146
142
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "woonplan-packages-redishelper",
3
- "version": "1.0.64",
3
+ "version": "1.0.68",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/setters.ts CHANGED
@@ -4,14 +4,14 @@ import { RedisMessage } from "./types"
4
4
  import { getMessageReponseKey, redisMessageToArrayOfKeysAndValues, reduceArraysToArray } from "./utils"
5
5
 
6
6
  const publishMessageResponse = ( client:Redis, messageid:string, message:string ) => {
7
- console.log( `publishing to ${messageid} at ${new Date().toISOString()}` )
7
+ //console.log( `publishing to ${messageid} at ${new Date().toISOString()}` )
8
8
  return client.publish( getMessageReponseKey( messageid ), message )
9
9
  }
10
10
 
11
11
 
12
12
  const sendMessageToStream = ( client:Redis, channelname:string, message:RedisMessage) => {
13
13
  const arrayOfKeysAndValues = redisMessageToArrayOfKeysAndValues( message ).reduce( reduceArraysToArray, [] );
14
- console.log( 'sendings message', channelname )
14
+ console.log( 'sending message', channelname )
15
15
  return client.xadd( channelname, '*', ...arrayOfKeysAndValues )
16
16
  }
17
17