woonplan-packages-redishelper 1.0.65 → 1.0.69

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.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.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { Redis } from "ioredis";
2
1
  import { RedisConfig, RedisMessage } from "./types";
3
2
  import { sendMessageToStream, publishMessageResponse } from "./setters";
4
3
  import { getOrRequestData, subscribeToMessageResponse, requestAndWaitForList } from "./getters";
5
- declare const listenToStream: (client: Redis, groupname: string, channelname: string, consumername: string, callback: Function) => Promise<boolean>;
4
+ declare const listenToStream: (config: RedisConfig, groupname: string, channelname: string, consumername: string, callback: Function) => Promise<boolean>;
6
5
  declare const dataRequester: (config: RedisConfig, groupname: string, service: string, consumername: string, callback: Function) => void;
7
6
  export { listenToStream, RedisMessage, sendMessageToStream, publishMessageResponse, getOrRequestData, dataRequester, subscribeToMessageResponse, requestAndWaitForList };
package/dist/index.js CHANGED
@@ -10,7 +10,8 @@ Object.defineProperty(exports, "subscribeToMessageResponse", { enumerable: true,
10
10
  Object.defineProperty(exports, "requestAndWaitForList", { enumerable: true, get: function () { return getters_1.requestAndWaitForList; } });
11
11
  var memdb_1 = require("./memdb");
12
12
  var utils_1 = require("./utils");
13
- var listenToStream = function (client, groupname, channelname, consumername, callback) { return new Promise(function (resolve, reject) {
13
+ var listenToStream = function (config, groupname, channelname, consumername, callback) { return new Promise(function (resolve, reject) {
14
+ var client = (0, memdb_1.getRedisClient)(config);
14
15
  createGroup(client, groupname, channelname).then(function () {
15
16
  listenForMessage(client, groupname, channelname, consumername, callback);
16
17
  resolve(true);
@@ -111,8 +112,6 @@ var listenForMessage = function (client, groupname, channelname, consumername, c
111
112
  client.xack(channelname, groupname, id).then(function () {
112
113
  console.log(id + ' acknowledged');
113
114
  });
114
- // in case somebody was subscribed to the response;
115
- (0, setters_1.publishMessageResponse)(client, id, '');
116
115
  // relisten
117
116
  listenForMessage(client, groupname, channelname, consumername, callback);
118
117
  });
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
@@ -5,7 +5,8 @@ import { getOrRequestData, subscribeToMessageResponse, requestAndWaitForList } f
5
5
  import { getRedisClient } from "./memdb"
6
6
  import { getKeyRequestedChannelName } from "./utils"
7
7
 
8
- const listenToStream = ( client:Redis, groupname:string, channelname:string, consumername:string, callback:Function ):Promise<boolean> => new Promise((resolve,reject) => {
8
+ const listenToStream = ( config:RedisConfig, groupname:string, channelname:string, consumername:string, callback:Function ):Promise<boolean> => new Promise((resolve,reject) => {
9
+ const client = getRedisClient( config )
9
10
  createGroup( client, groupname, channelname ).then(
10
11
  ( ) => {
11
12
  listenForMessage( client, groupname, channelname, consumername, callback );
@@ -137,10 +138,6 @@ const listenForMessage = ( client:Redis, groupname:string, channelname:string, c
137
138
  client.xack( channelname, groupname, id ).then( () => {
138
139
  console.log( id + ' acknowledged')
139
140
  })
140
-
141
- // in case somebody was subscribed to the response;
142
- publishMessageResponse( client, id, '' );
143
-
144
141
  // relisten
145
142
  listenForMessage( client, groupname, channelname, consumername, callback );
146
143
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "woonplan-packages-redishelper",
3
- "version": "1.0.65",
3
+ "version": "1.0.69",
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