2020-11-08 - Message Config Manager - Functions
Jump to navigation
Jump to search
Service - Message Config Manager
Lambda Functions
pullMsgCfgs
/**
* Connects to an external services Lambda that returns that services msgCfgs, stores these into local table
* @param {string} event.serviceName - for now handle one service at a time
*
* @returns {Object} msgCfgs
*/
module.exports.pullMsgCfgs = async (event) => {
logic
- query Config table for event.serviceName record
- query #MsgCfg table all msgCfg's for event.serviceName, place into var existingMsgCfgs
- do an sync Lambda invocation, Lambda function name concatenate {event.serviceName} + "GetMsgCfgs"
- if lambda error throw error "Unable to find service endpoint " + {Lambda function name}
- if Config table record not exist, create a record
- for each msgCfgs
- if not exist in existingMsgCfgs or changed
- insert/update record in #MsgCfg table
- send a message to OutMsgCfgUpdate queue with new msgCfg details
- if not exist in existingMsgCfgs or changed
update 2021-05-10
- external service returns msgCfg without serviceName set, we add this here before saving to Dynamo etc
getServiceNames
/**
* Returns all serviceNames managed by this service
*
* @returns {Object} serviceNames
*/
module.exports.getServiceNames = async () => {
logic
- query Config table and return all configKey = serviceName
getMsgCfgs
/**
* Returns all msgCfgs for one serviceName
* @param {string} serviceName - for now return results for one service at a time
*
* @returns {Object} msgCfgs
*/
module.exports.getMsgCfgs = async (serviceName) => {
handler
- passes on serviceName from event object
logic
- query MsgCfgs table and return all that match serviceName
getMsgCfg
/**
* Returns one msgCfg
* @param {string} serviceName
* @param {string} topicName
*
* @returns {Object} msgCfg
*/
module.exports.getMsgCfg = async (serviceName) => {
HdrInv
- passes on serviceName and topicName from request
logic
- query MsgCfgs table and return matching record
- also return current timestamp (maybe create timestamp inside Dynamo query for more accurate snapshot time)