-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
refactor(core): Generalize binary data manager interface (no-changelog) #7164
refactor(core): Generalize binary data manager interface (no-changelog) #7164
Conversation
Great PR! Please pay attention to the following items before merging: Files matching
Files matching
Files matching
Make sure to check off this list before asking for review. |
@@ -900,9 +893,9 @@ export const schema = { | |||
}, | |||
}, | |||
|
|||
binaryDataManager: { | |||
binaryDataService: { | |||
availableModes: { |
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.
Renaming this is a breaking change, and should be documented in BREAKING-CHANGES.md
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.
Reverted: 605d02b
Maybe in future we can bundle all changes like this together, to minimize annoyance for users.
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.
if we are reverting, can we revert all of the renaming, and not just the config? either that, or we don't revert and list this as a breaking change.
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.
I think there is benefit in a temporary middle ground. Preexisting code uses "manager" for both binary data manager and its modes, so it's rather confusing and inconsistent. With this division into service and managers, the distinction is clearer, and the inconsistency is reduced to only this handful of entrypoint config spots where the renaming would cause a breaking change. So on balance the bulk of code becomes clearer.
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.
LGTM
if (this.availableModes.includes('filesystem') && config.mode === 'filesystem') { | ||
this.managers.filesystem = new FileSystemManager(config.localStoragePath); | ||
|
||
await this.managers.filesystem.init(); |
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.
Loading this conditionally means that if we switch back to default
after using filesystem
for a while means we cannot read previous executions anymore. Given we want to allow people to switch freely between modes, I think we always have to init all managers based on the available
modes rather than the default
one, wdyt?
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.
Thank you, please see 20d5ea7
.
import type { BinaryData } from './types'; | ||
|
||
const EXECUTION_ID_EXTRACTOR = | ||
/^(\w+)(?:[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})$/; |
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.
For learning only, this regular expression can be simplified to use lazy operator instead of lookahead, which is a bit more expensive. Feel free to ignore.
/^(\w+)(?:[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})$/; | |
/^(.*?)([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})$/; |
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.
Love it, I didn't know this. Since there are no tests and we will be refactoring this in future, for now I'll keep it as it was beforehand.
* - `filesystem` (on disk) | ||
* - `object` (S3) | ||
*/ | ||
export const BINARY_DATA_MODES = ['default', 'filesystem', 'object'] as const; |
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.
The name object
makes me think of the native js Object and I have a tendency to think this is somewhat related to a hash map.
What about just calling it S3 since this is what it does reflect?
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.
Please see 0cdfb79
1 flaky test on run #2252 ↗︎
Details:
cypress/e2e/24-ndv-paired-item.cy.ts • 1 flaky test
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
✅ All Cypress E2E specs passed |
Small note: for some reason I'm getting this on my terminal:
When viewing executions. Any ideas @ivov ? Edit: feel free to ignore, I can no longer reproduce this issue. I guess I was running an old build. |
`LogCatch` was merged into master at a different file: `/packages/core/binaryData/index.ts`, which is now at `BinaryData.service.ts`
Unable to reproduce, messaging you for more details. |
✅ All Cypress E2E specs passed |
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.
LGTM
✅ All Cypress E2E specs passed |
…ager interface (no-changelog) (#7195) Depends on: #7164 | Story: [PAY-838](https://linear.app/n8n/issue/PAY-838/introduce-object-store-service-for-binary-data) This PR removes `storeMetadata` and `getSize` from the binary data manager interface, as these are specific to filesystem mode. Also this disambiguates identifiers: ``` binaryDataId filesystem:289b4aac51e-dac6-4167-b793-6d5c415e2b47 {mode}:{fileId} fileId - FS 289b4aac51e-dac6-4167-b793-6d5c415e2b47 {executionId}{uuid} fileId - S3 /workflows/{workflowId}/executions/{executionId}/binary_data/b4aac51e-dac6-4167-b793-6d5c415e2b47 ``` Note: The object store changes originally in this PR were extracted out into the final PR. --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <[email protected]>
Got released with |
Depends on: #7092 | Story: PAY-768
This PR:
IBinaryDataManager
interface.Filesystem.ts
to satisfy the interface.BinaryDataManager
into an injectable service.Note that the PR looks large but all the main changes are in
packages/core/src/binaryData
.Out of scope:
BinaryDataManager
(nowBinaryDataService
) andFilesystem.ts
(nowfs.client.ts
) were slightly refactored for maintainability, but fully overhauling them is not the focus of this PR, which is meant to clear the way for the S3 implementation. Future improvements for these two should include setting up a backwards-compatible dir structure that makes it easier to locate binary data files to delete, removing duplication, simplifying cloning methods, using integers for binary data size instead ofprettyBytes()
, writing tests for existing binary data logic, etc.