-
-
Notifications
You must be signed in to change notification settings - Fork 347
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
Filter addFiles between hooks #370
base: v3
Are you sure you want to change the base?
Conversation
* Make addFiles call files-added hook with a file list filtered by every individual file-added like in v2 and old synchronous v3 functions * Cleanup: removed the intermediary state objects and array * Cleanup: rename flowfiles array to flowFiles
92e9218
to
827ecf4
Compare
827ecf4
to
a44217c
Compare
var flowfiles = await Promise.all(states); | ||
for (let ff of flowfiles) { | ||
await this.hook('file-added', ff, event); | ||
if(flowFile && flowFile.file) { |
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.
formatting is off, space should be placed after an if
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've a problem with this. When multiple files are added this is expected to be a (mostly) independent process for each of them.
Accumulating the (async) bootstrap (and possibly async initFileFn
) then waiting for all of them at once is superior as it allows for parallel non-blocking initialization processes to occurs (FlowFile.bootstrap()
).
Then, only file-added
hooks were run sequentially (await
ing in a loop for each of them).
With this change, we'd now wait twice in a loop. It's inefficient and contrary to parallelization abilities offered by Promises.
(While talking about this, would you mind having a look at #368?)
it('should validate file-added filtering before files-added', async function() { | ||
var valid = false; | ||
flow.on('file-added', (flowFile) => { | ||
if(flowFile.name === 'f2') { |
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.
formatting is off, space should be placed after an if
files-added
hook with a file list filtered by every individualfile-added
hookfiles-added
hook won't receive files thatfile-added
has deleted