Skip to content

Commit

Permalink
refactor(fargate): emit phase started and completed events from workers
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardobridge committed Feb 6, 2024
1 parent 0d740cb commit cc71c23
Showing 1 changed file with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,54 @@ function ArtillerySQSPlugin(script, events) {
});
});

events.on('phaseStarted', (phaseContext) => {
this.unsent++;
const body = JSON.stringify({
event: 'phaseStarted',
phase: phaseContext
});

const params = {
MessageBody: body,
QueueUrl: this.queueUrl,
MessageAttributes: this.messageAttributes,
MessageDeduplicationId: uuid(),
MessageGroupId: this.testId
};

this.sqs.sendMessage(params, (err, data) => {
if (err) {
console.error(err);
}

this.unsent--;
});
});

events.on('phaseCompleted', (phaseContext) => {
this.unsent++;
const body = JSON.stringify({
event: 'phaseCompleted',
phase: phaseContext
});

const params = {
MessageBody: body,
QueueUrl: this.queueUrl,
MessageAttributes: this.messageAttributes,
MessageDeduplicationId: uuid(),
MessageGroupId: this.testId
};

this.sqs.sendMessage(params, (err, data) => {
if (err) {
console.error(err);
}

this.unsent--;
});
});

events.on('done', (_stats) => {
this.unsent++;
const body = JSON.stringify({
Expand Down

0 comments on commit cc71c23

Please sign in to comment.