-
Notifications
You must be signed in to change notification settings - Fork 0
Format s3 key #432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Format s3 key #432
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,11 @@ startDockerContainers() { | |
| yes | ./db/flyway.sc migrate local | ||
| } | ||
|
|
||
| startQueueingLambda() { | ||
| pushd "$ROOT_DIR/fingerpost-queueing-lambda" | ||
| npm install | ||
| npm run dev | ||
| } | ||
| startIngestionLambda() { | ||
| pushd "$ROOT_DIR/ingestion-lambda" | ||
| npm install | ||
|
|
@@ -100,7 +105,7 @@ main() { | |
| echo "Using the local stack. Starting Docker, Ingestion Lambda and Play App." | ||
| startDockerContainers | ||
| # run all three, and terminate together when the user presses `ctrl+c`: https://stackoverflow.com/a/52033580 | ||
| (trap 'kill 0' SIGINT; startIngestionLambda & startPlayApp & wait) | ||
| (trap 'kill 0' SIGINT; startQueueingLambda & startIngestionLambda & startPlayApp & wait) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤩 |
||
| fi | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { formatS3Key } from "./formatS3key"; | ||
|
|
||
| describe('formatS3Key', () => { | ||
| it('should format the S3 key with the external ID and .json extension', () => { | ||
| const externalId = 'test-external-id'; | ||
| const expectedKey = 'test-external-id.json'; | ||
| expect(formatS3Key(externalId)).toBe(expectedKey); | ||
| }); | ||
| it('should replace spaces with a hyphen', () => { | ||
| const externalId = 'test external id'; | ||
| const expectedKey = 'test-external-id.json'; | ||
| expect(formatS3Key(externalId)).toBe(expectedKey); | ||
| }); | ||
| it('should replace forward slashes with a hyphen', () => { | ||
| const externalId = 'test/external/id'; | ||
| const expectedKey = 'test-external-id.json'; | ||
| expect(formatS3Key(externalId)).toBe(expectedKey); | ||
|
Comment on lines
+5
to
+17
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this run the risk that some stories might overwrite each other in S3? if we had 3 files arrive with each of these external ids, then we'd be left with only the most recent, even though they've each got different ids. (Hopefully actually we still have all 3, but only as versions of object with the same key).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main thing with the spaced and slashed keys is we end up with a lot of documents with the key name as Though yeah, I do get that doing our own manipulation could have some risks when we want to ensure the key is the identifier. What would be the benefit of a URLEncoder instead?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you both think? A problem worth addressing or prefer to leave as is? |
||
| }) | ||
| });; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export function formatS3Key(externalId: string): string { | ||
| return externalId.replace(/\s+/g, '-').replace(/\//g, '-').concat('.json'); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Should the formatting be fingerpost-specific or apply to all items going via S3? If the latter, should we add this to the poller lambdas too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good thought. Do we store the original id anywhere with the poller lambdas?
I felt like doing some manipulation here was safe because we have the externalId in the database to cross reference.
Whereas with the poller lambda I don't know whether we might not want to risk any additional manipulation? Though, I also think it's nicer to store the records in this way.
@andrew-nowak do you have any thoughts?