Skip to content

Commit

Permalink
Merge pull request #36 from topcoder-platform/dev
Browse files Browse the repository at this point in the history
add new feature - key
  • Loading branch information
nkumar-topcoder authored Jun 17, 2021
2 parents 2d9daa2 + 07515c0 commit 7fe790b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ workflows:
context : org-global
filters:
branches:
only: ['dev']
only: ['dev', 'feature/shapeup3']
- "build-prod":
context : org-global
filters:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Topcoder Bus API Server

## Overview
## Overview

A meta service, Topcoder Bus API server provides information about other services offered by Topcoder.

Expand Down
4 changes: 4 additions & 0 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,10 @@ definitions:
type: "string"
example: "application/json"
description: "Mime-type for 'payload'.\n"
key:
type: "string"
example: "abc123"
description: "optional field to assure the one partition for 'payload'.\n"
payload:
type: "object"
example:
Expand Down
1 change: 1 addition & 0 deletions common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ function validateEventPayload (event) {
originator: Joi.string().required(),
timestamp: Joi.string().required(),
'mime-type': Joi.string().required(),
key: Joi.string(),
payload: Joi.any()
})
})
Expand Down
15 changes: 10 additions & 5 deletions service/MessageBusService.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ async function postEvent (event) {
helper.validateEventPayload(event)

// Post new structure
const result = await producer.send({
const message = {
value: JSON.stringify(event)
}
if (event.key) {
_.merge(message, { key: event.key })
}
const kafkaPayload = {
topic: event.topic,
message: {
value: JSON.stringify(event)
}
})
message
}
const result = await producer.send(kafkaPayload)
// Check if there is any error
const error = _.get(result, '[0].error')
if (error) {
Expand Down

0 comments on commit 7fe790b

Please sign in to comment.