diff --git a/.circleci/config.yml b/.circleci/config.yml index fd2157e..50fba99 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -77,7 +77,7 @@ workflows: context : org-global filters: branches: - only: ['dev'] + only: ['dev', 'feature/shapeup3'] - "build-prod": context : org-global filters: diff --git a/README.md b/README.md index 79d9742..54a0a22 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/api/swagger.yaml b/api/swagger.yaml index 597555c..ea31cd2 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -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: diff --git a/common/helper.js b/common/helper.js index 386d30f..8e3993e 100644 --- a/common/helper.js +++ b/common/helper.js @@ -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() }) }) diff --git a/service/MessageBusService.js b/service/MessageBusService.js index cb21b3b..dceb6e6 100644 --- a/service/MessageBusService.js +++ b/service/MessageBusService.js @@ -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) {