Skip to content

Commit 07515c0

Browse files
Merge pull request #35 from topcoder-platform/feature/shapeup3
Feature/shapeup3 - adding `key` feature
2 parents b41af6d + 52bb17a commit 07515c0

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ workflows:
7777
context : org-global
7878
filters:
7979
branches:
80-
only: ['dev']
80+
only: ['dev', 'feature/shapeup3']
8181
- "build-prod":
8282
context : org-global
8383
filters:

api/swagger.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,10 @@ definitions:
979979
type: "string"
980980
example: "application/json"
981981
description: "Mime-type for 'payload'.\n"
982+
key:
983+
type: "string"
984+
example: "abc123"
985+
description: "optional field to assure the one partition for 'payload'.\n"
982986
payload:
983987
type: "object"
984988
example:

common/helper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ function validateEventPayload (event) {
133133
originator: Joi.string().required(),
134134
timestamp: Joi.string().required(),
135135
'mime-type': Joi.string().required(),
136+
key: Joi.string(),
136137
payload: Joi.any()
137138
})
138139
})

service/MessageBusService.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@ async function postEvent (event) {
3030
helper.validateEventPayload(event)
3131

3232
// Post new structure
33-
const result = await producer.send({
33+
const message = {
34+
value: JSON.stringify(event)
35+
}
36+
if (event.key) {
37+
_.merge(message, { key: event.key })
38+
}
39+
const kafkaPayload = {
3440
topic: event.topic,
35-
message: {
36-
value: JSON.stringify(event)
37-
}
38-
})
41+
message
42+
}
43+
const result = await producer.send(kafkaPayload)
3944
// Check if there is any error
4045
const error = _.get(result, '[0].error')
4146
if (error) {

0 commit comments

Comments
 (0)