Skip to content

Commit

Permalink
feat: algolia v1 proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik committed Mar 6, 2024
1 parent 4dccbdf commit 1d42582
Show file tree
Hide file tree
Showing 2 changed files with 914 additions and 6 deletions.
50 changes: 44 additions & 6 deletions src/cdk/v2/destinations/algolia/rtWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ bindings:
- path: ../../../../v0/destinations/algolia/config
- name: handleRtTfSingleEventError
path: ../../../../v0/util/index
- path: ./util
steps:
- name: validateInput
template: |
Expand All @@ -28,14 +27,47 @@ steps:
$.outputs.transform#idx.error.(
$.handleRtTfSingleEventError(^[idx], .originalError ?? ., {})
)[]
- name: separateDontBatchEventForProxy
template: |
const payload = $.constructFullPayload(^, $.outputs.successfulEvents);
payload
- name: batchSuccessfulEvents
{
dontBatchTrueEvents: $.outputs.successfulEvents{.metadata.dontBatch}[],
dontBatchFalseEvents: $.outputs.successfulEvents{!.metadata.dontBatch}[]
}
- name: batchSuccessfulEventsDontBatchTrue
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
})[];
- name: batchSuccessfulEventsDontBatchFalse
description: Batches the successfulEvents
template: |
let batches = $.chunk($.outputs.successfulEvents, $.MAX_BATCH_SIZE);
let batches = $.chunk($.outputs.separateDontBatchEventForProxy.dontBatchFalseEvents, $.MAX_BATCH_SIZE);
batches@batch.({
"batchedRequest": {
"body": {
Expand All @@ -60,6 +92,12 @@ steps:
"statusCode": 200,
"destination": batch[0].destination
})[];
- name: combineSuccessfulEvents
description: Combines the successfulEvents
template: |
[...$.outputs.batchSuccessfulEventsDontBatchFalse, ...$.outputs.batchSuccessfulEventsDontBatchTrue]
- name: finalPayload
template: |
[...$.outputs.failedEvents, ...$.outputs.batchSuccessfulEvents]
[...$.outputs.failedEvents, ...$.outputs.combineSuccessfulEvents]
Loading

0 comments on commit 1d42582

Please sign in to comment.