-
Notifications
You must be signed in to change notification settings - Fork 28
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
John Gilbert
committed
Sep 20, 2024
1 parent
3849f80
commit 22cf94f
Showing
7 changed files
with
92 additions
and
25 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import _ from 'highland'; | ||
|
||
import { putObjectToS3 } from './s3'; | ||
|
||
// // claim-check pattern support | ||
// // https://www.enterpriseintegrationpatterns.com/patterns/messaging/StoreInLibrary.html | ||
|
||
export const toClaimcheckEvent = (event, bucket) => ({ | ||
id: event.id, | ||
type: event.type, | ||
partitionKey: event.partitionKey, | ||
timestamp: event.timestamp, | ||
tags: event.tags, | ||
s3: { | ||
bucket, | ||
key: `claimchecks/${event.id}`, | ||
}, | ||
}); | ||
|
||
export const toPutClaimcheckRequest = (event, Bucket) => ({ | ||
Bucket, | ||
Key: `claimchecks/${event.id}`, | ||
Body: JSON.stringify(event), | ||
}); | ||
|
||
export const storeClaimcheck = ({ | ||
id: pipelineId, | ||
claimCheckBucketName = process.env.CLAIMCHECK_BUCKET_NAME, | ||
putClaimcheckRequest = 'putClaimcheckRequest', | ||
putClaimcheckResponse = 'putClaimcheckResponse', | ||
parallel = Number(process.env.S3_PARALLEL) || Number(process.env.PARALLEL) || 8, | ||
debug, | ||
step, | ||
...opt | ||
}) => { | ||
// if we don't have a bucket we can't claimcheck | ||
if (!claimCheckBucketName) return (s) => s; | ||
|
||
return (s) => s | ||
.flatMap((batch) => | ||
_(batch) | ||
.through(putObjectToS3({ | ||
debug, | ||
id: pipelineId, | ||
bucketName: claimCheckBucketName, | ||
putRequestField: putClaimcheckRequest, | ||
putResponseField: putClaimcheckResponse, | ||
parallel, | ||
step, | ||
...opt, | ||
})) | ||
.collect()); | ||
}; |
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
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