-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
539b90f
commit 17b086e
Showing
3 changed files
with
11 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,7 @@ const positions = async (error, messages) => { | |
// Iterate through consumedMessages | ||
const bins = {} | ||
const lastPerPartition = {} | ||
for (const message of consumedMessages) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kalinkrustev
Author
Contributor
|
||
await Promise.all(consumedMessages.map(message => { | ||
const histTimerMsgEnd = Metrics.getHistogram( | ||
'transfer_position', | ||
'Process a prepare transfer message', | ||
|
@@ -126,8 +126,8 @@ const positions = async (error, messages) => { | |
lastPerPartition[message.partition] = message | ||
} | ||
|
||
await span.audit(message, EventSdk.AuditEventAction.start) | ||
} | ||
return span.audit(message, EventSdk.AuditEventAction.start) | ||
})) | ||
|
||
// Start DB Transaction | ||
const trx = await BatchPositionModel.startDbTransaction() | ||
|
@@ -148,12 +148,12 @@ const positions = async (error, messages) => { | |
await trx.commit() | ||
|
||
// Loop through results and produce notification messages and audit messages | ||
for (const item of result.notifyMessages) { | ||
await Promise.all(result.notifyMessages.map(item => { | ||
// Produce notification message and audit message | ||
const action = item.binItem.message?.value.metadata.event.action | ||
const eventStatus = item?.message.metadata.event.state.status === Enum.Events.EventStatus.SUCCESS.status ? Enum.Events.EventStatus.SUCCESS : Enum.Events.EventStatus.FAILURE | ||
await Kafka.produceGeneralMessage(Config.KAFKA_CONFIG, Producer, Enum.Events.Event.Type.NOTIFICATION, action, item.message, eventStatus, null, item.binItem.span) | ||
} | ||
return Kafka.produceGeneralMessage(Config.KAFKA_CONFIG, Producer, Enum.Events.Event.Type.NOTIFICATION, action, item.message, eventStatus, null, item.binItem.span) | ||
})) | ||
histTimerEnd({ success: true }) | ||
} catch (err) { | ||
// If Bin Processor returns failure | ||
|
HI @kalinkrustev is it safe to use promise.all for consumedMessages instead of for loop? Don't we get race conditions?
May be we can span.audit can be taken out of the for loop and using Promise.all for that?