Skip to content

Commit

Permalink
fix: comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik committed Mar 7, 2024
1 parent f6b6607 commit 1b3ab44
Showing 1 changed file with 5 additions and 43 deletions.
48 changes: 5 additions & 43 deletions src/cdk/v2/destinations/algolia/rtWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,13 @@ steps:
$.handleRtTfSingleEventError(^[idx], .originalError ?? ., {})
)[]
- name: separateDontBatchEventForProxy
template: |
{
dontBatchTrueEvents: $.outputs.successfulEvents{.metadata.dontBatch}[],
dontBatchFalseEvents: $.outputs.successfulEvents{!.metadata.dontBatch}[]
}
- name: batchSuccessfulEventsDontBatchTrue
- name: batchSuccessfulEvents
description: Batches the successfulEvents
template: |
let batches = $.chunk($.outputs.separateDontBatchEventForProxy.dontBatchTrueEvents, 1);
batches@batch.({
"batchedRequest": {
"body": {
"JSON": {"events": ~r batch.output[]},
"JSON_ARRAY": {},
"XML": {},
"FORM": {}
},
"version": "1",
"type": "REST",
"method": "POST",
"endpoint": {{$.ENDPOINT}},
"headers": batch[0].destination.Config.().({
"X-Algolia-Application-Id": .applicationId,
"X-Algolia-API-Key": .apiKey
}),
"params": {},
"files": {}
},
"metadata": ~r batch.metadata[],
"batched": true,
"statusCode": 200,
"destination": batch[0].destination
})[];
const dontBatchTrueEvents = $.outputs.successfulEvents{.metadata.dontBatch}[];
const dontBatchFalseEvents = $.outputs.successfulEvents{!.metadata.dontBatch}[];
- name: batchSuccessfulEventsDontBatchFalse
description: Batches the successfulEvents
template: |
let batches = $.chunk($.outputs.separateDontBatchEventForProxy.dontBatchFalseEvents, $.MAX_BATCH_SIZE);
let batches = [...$.chunk(dontBatchFalseEvents, $.MAX_BATCH_SIZE), ...$.chunk(dontBatchTrueEvents, 1)];
batches@batch.({
"batchedRequest": {
"body": {
Expand All @@ -93,11 +60,6 @@ steps:
"destination": batch[0].destination
})[];
- name: combineSuccessfulEvents
description: Combines the successfulEvents
template: |
[...$.outputs.batchSuccessfulEventsDontBatchFalse, ...$.outputs.batchSuccessfulEventsDontBatchTrue]
- name: finalPayload
template: |
[...$.outputs.failedEvents, ...$.outputs.combineSuccessfulEvents]
[...$.outputs.failedEvents, ...$.outputs.batchSuccessfulEvents]

0 comments on commit 1b3ab44

Please sign in to comment.