This commit is contained in:
Brian Cao 2022-08-25 22:43:22 -07:00
parent 7e9ed704cc
commit f499af5491
3 changed files with 32 additions and 14 deletions

View file

@ -44,18 +44,18 @@ let kafkaProducer = null;
export { kafka, kafkaProducer };
export async function getProducer() {
async function getProducer() {
const producer = kafka.producer();
await producer.connect();
return producer;
}
export function getDateFormat(date) {
function getDateFormat(date) {
return dateFormat(date, 'UTC:yyyy-mm-dd HH:MM:ss');
}
export async function sendMessage(params, topic) {
async function sendMessage(params, topic) {
await kafkaProducer.send({
topic,
messages: [
@ -67,3 +67,8 @@ export async function sendMessage(params, topic) {
acks: 0,
});
}
export default {
getDateFormat,
sendMessage,
};