@hotmeshio/hotmesh 0.1.1 → 0.1.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.
- package/README.md +2 -2
- package/build/package.json +1 -1
- package/build/services/activities/activity.js +1 -1
- package/build/services/activities/await.js +1 -1
- package/build/services/activities/cycle.js +1 -1
- package/build/services/activities/hook.js +1 -1
- package/build/services/activities/interrupt.js +1 -1
- package/build/services/activities/signal.js +1 -1
- package/build/services/activities/trigger.js +1 -1
- package/build/services/activities/worker.js +1 -1
- package/build/services/store/clients/ioredis.d.ts +3 -3
- package/build/services/store/clients/ioredis.js +10 -7
- package/build/services/store/clients/redis.d.ts +3 -3
- package/build/services/store/clients/redis.js +10 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
HotMesh transforms Redis into an Orchestration Engine.
|
|
5
5
|
|
|
6
|
-
*Write functions in your own
|
|
6
|
+
*Write functions in your own style, and let Redis govern their execution, reliably and durably.*
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
[](https://badge.fury.io/js/%40hotmeshio%2Fhotmesh)
|
|
@@ -13,7 +13,7 @@ npm install @hotmeshio/hotmesh
|
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Understanding HotMesh
|
|
16
|
-
HotMesh inverts the relationship to Redis: those functions that once used Redis as a cache, are instead *cached and governed* by Redis. Consider the following. It's a typical microservices network, with a tangled mess of services and functions. There's important business logic in there (functions *A*, *B* and *C* are critical
|
|
16
|
+
HotMesh inverts the relationship to Redis: those functions that once used Redis as a cache, are instead *cached and governed* by Redis. Consider the following. It's a typical microservices network, with a tangled mess of services and functions. There's important business logic in there (functions *A*, *B* and *C* are critical), but it's hard to find and access.
|
|
17
17
|
|
|
18
18
|
<img src="./docs/img/operational_data_layer.png" alt="A Tangled Microservices Network with 3 valuable functions buried within" style="max-width:100%;width:600px;">
|
|
19
19
|
|
package/build/package.json
CHANGED
|
@@ -15,9 +15,9 @@ declare class IORedisStoreService extends StoreService<RedisClientType, RedisMul
|
|
|
15
15
|
constructor(redisClient: RedisClientType);
|
|
16
16
|
/**
|
|
17
17
|
* When in cluster mode, the getMulti wrapper only
|
|
18
|
-
* sends commands to the same node/shard.
|
|
19
|
-
* All other commands are sent
|
|
20
|
-
*
|
|
18
|
+
* sends commands to the same node/shard if they share a key.
|
|
19
|
+
* All other commands are sent simultaneouslyusing Promise.all
|
|
20
|
+
* and are then collated
|
|
21
21
|
*/
|
|
22
22
|
getMulti(): RedisMultiType;
|
|
23
23
|
exec(...args: any[]): Promise<string | string[] | string[][]>;
|
|
@@ -3,19 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.IORedisStoreService = void 0;
|
|
4
4
|
const key_1 = require("../../../modules/key");
|
|
5
5
|
const index_1 = require("../index");
|
|
6
|
+
const enums_1 = require("../../../modules/enums");
|
|
6
7
|
class IORedisStoreService extends index_1.StoreService {
|
|
7
8
|
constructor(redisClient) {
|
|
8
9
|
super(redisClient);
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* When in cluster mode, the getMulti wrapper only
|
|
12
|
-
* sends commands to the same node/shard.
|
|
13
|
-
* All other commands are sent
|
|
14
|
-
*
|
|
13
|
+
* sends commands to the same node/shard if they share a key.
|
|
14
|
+
* All other commands are sent simultaneouslyusing Promise.all
|
|
15
|
+
* and are then collated
|
|
15
16
|
*/
|
|
16
17
|
getMulti() {
|
|
17
18
|
const my = this;
|
|
18
|
-
if (
|
|
19
|
+
if (enums_1.HMSH_IS_CLUSTER) {
|
|
19
20
|
const commands = [];
|
|
20
21
|
const addCommand = (command, args) => {
|
|
21
22
|
commands.push({ command, args });
|
|
@@ -28,12 +29,14 @@ class IORedisStoreService extends index_1.StoreService {
|
|
|
28
29
|
async exec() {
|
|
29
30
|
if (commands.length === 0)
|
|
30
31
|
return [];
|
|
31
|
-
const
|
|
32
|
-
|
|
32
|
+
const sameKey = commands.every(cmd => {
|
|
33
|
+
return cmd.args[0] === commands[0].args[0];
|
|
34
|
+
});
|
|
35
|
+
if (sameKey) {
|
|
33
36
|
const multi = my.redisClient.multi();
|
|
34
37
|
commands.forEach(cmd => multi[cmd.command](...cmd.args));
|
|
35
38
|
const results = await multi.exec();
|
|
36
|
-
return results.map(item => item);
|
|
39
|
+
return results.map(item => item);
|
|
37
40
|
}
|
|
38
41
|
else {
|
|
39
42
|
return Promise.all(commands.map(cmd => my.redisClient[cmd.command](...cmd.args)));
|
|
@@ -16,9 +16,9 @@ declare class RedisStoreService extends StoreService<RedisClientType, RedisMulti
|
|
|
16
16
|
constructor(redisClient: RedisClientType);
|
|
17
17
|
/**
|
|
18
18
|
* When in cluster mode, the getMulti wrapper only
|
|
19
|
-
* sends commands to the same node/shard.
|
|
20
|
-
* All other commands are sent
|
|
21
|
-
*
|
|
19
|
+
* sends commands to the same node/shard if they share a key.
|
|
20
|
+
* All other commands are sent simultaneouslyusing Promise.all
|
|
21
|
+
* and are then collated
|
|
22
22
|
*/
|
|
23
23
|
getMulti(): RedisMultiType;
|
|
24
24
|
exec(...args: any[]): Promise<string | string[] | string[][]>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RedisStoreService = void 0;
|
|
4
4
|
const index_1 = require("../index");
|
|
5
|
+
const enums_1 = require("../../../modules/enums");
|
|
5
6
|
class RedisStoreService extends index_1.StoreService {
|
|
6
7
|
constructor(redisClient) {
|
|
7
8
|
super(redisClient);
|
|
@@ -38,13 +39,13 @@ class RedisStoreService extends index_1.StoreService {
|
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
41
|
* When in cluster mode, the getMulti wrapper only
|
|
41
|
-
* sends commands to the same node/shard.
|
|
42
|
-
* All other commands are sent
|
|
43
|
-
*
|
|
42
|
+
* sends commands to the same node/shard if they share a key.
|
|
43
|
+
* All other commands are sent simultaneouslyusing Promise.all
|
|
44
|
+
* and are then collated
|
|
44
45
|
*/
|
|
45
46
|
getMulti() {
|
|
46
47
|
const my = this;
|
|
47
|
-
if (
|
|
48
|
+
if (enums_1.HMSH_IS_CLUSTER) {
|
|
48
49
|
const commands = [];
|
|
49
50
|
const addCommand = (command, args) => {
|
|
50
51
|
commands.push({ command: command.toUpperCase(), args });
|
|
@@ -57,8 +58,10 @@ class RedisStoreService extends index_1.StoreService {
|
|
|
57
58
|
async exec() {
|
|
58
59
|
if (commands.length === 0)
|
|
59
60
|
return [];
|
|
60
|
-
const
|
|
61
|
-
|
|
61
|
+
const sameKey = commands.every(cmd => {
|
|
62
|
+
return cmd.args[0] === commands[0].args[0];
|
|
63
|
+
});
|
|
64
|
+
if (sameKey) {
|
|
62
65
|
const multi = my.redisClient.multi();
|
|
63
66
|
commands.forEach(cmd => {
|
|
64
67
|
if (cmd.command === 'ZADD') {
|
|
@@ -67,7 +70,7 @@ class RedisStoreService extends index_1.StoreService {
|
|
|
67
70
|
return multi[cmd.command](...cmd.args);
|
|
68
71
|
});
|
|
69
72
|
const results = await multi.exec();
|
|
70
|
-
return results.map(item => item);
|
|
73
|
+
return results.map(item => item);
|
|
71
74
|
}
|
|
72
75
|
else {
|
|
73
76
|
return Promise.all(commands.map(cmd => {
|