Skip to content

Commit c358bfe

Browse files
author
Olha Virolainen
authored
Add Ability to pass data from the individual messages to re-assembled message (#69)
Add Ability to pass data from the individual messages to re-assembled message
1 parent 7eadec5 commit c358bfe

File tree

7 files changed

+4311
-18
lines changed

7 files changed

+4311
-18
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.2.0 (July 9, 2021)
2+
* Add Ability to pass data from the individual messages to re-assembled message
3+
14
## 1.1.9 (February 12, 2021)
25
* Update sailor version to 2.6.24
36

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,17 @@ If at any point there is more than a 15 second gap in messages, then the group w
112112
* The group is dropped if there are any unexpected restarts to the container.
113113
* Size of the group must be known by all group members.
114114
* Messages are only emitter when all parts arrive. Emitting a message only when the first part arrives isn't supported.
115-
* The contents of data that are picked up by the sub-messages aren't passed forward to future steps.
116115

117116
#### List of Expected Config fields
118117
```groupSize``` - Number of messages in the group
118+
119119
```groupId``` - Globally unique id for the group to distinguish it from other groups. This value needs to be the same for all messages in a group.
120+
120121
```messageId``` - Id for a message to distinguish it from other messages in the group.
121122
Must be unique per group but does not have to be globally unique. This value needs to be different for all messages in a group.
122123

124+
```messageData``` - object for providing some data derived from the steps between splitting and re-assembling
125+
123126
## Known limitations (common for the component)
124127
No.
125128

component.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"title": "Splitter",
3+
"version": "1.2.0",
34
"description": "Splits a message into multiple messages.",
45
"buildType":"docker",
56
"actions": {
@@ -61,6 +62,12 @@
6162
"type": "string",
6263
"required": true,
6364
"title": "Unique ID to describe this message"
65+
},
66+
"messageData": {
67+
"title": "Message Data",
68+
"required": false,
69+
"type": "object",
70+
"properties": {}
6471
}
6572
}
6673
}

lib/actions/reassemble.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ async function processAction(msg) {
77
groupSize,
88
groupId,
99
messageId,
10+
messageData,
1011
} = msg.body;
1112

1213
if (groupSize <= 0) {
@@ -17,10 +18,12 @@ async function processAction(msg) {
1718
groupsSeen[groupId] = {
1819
groupSize,
1920
messageIdsSeen: new Set(),
21+
incomingData: {},
2022
};
2123
}
2224

2325
groupsSeen[groupId].messageIdsSeen.add(messageId);
26+
groupsSeen[groupId].incomingData[messageId] = messageData;
2427
const numberSeen = groupsSeen[groupId].messageIdsSeen.size;
2528

2629
this.logger.info(
@@ -31,6 +34,7 @@ async function processAction(msg) {
3134
await this.emit('data', messages.newMessageWithBody({
3235
groupSize,
3336
groupId,
37+
messageData: groupsSeen[groupId].incomingData,
3438
}));
3539
delete groupsSeen[groupId];
3640
}

0 commit comments

Comments
 (0)