Skip to content
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

feat(storage-browser): add useProcessTasks #5905

Conversation

calebpollman
Copy link
Member

@calebpollman calebpollman commented Oct 15, 2024

Description of changes

Add useProcessTasks utility hook for usage in batch action default and custom views, e.g. Upload, Copy, etc

Issue #, if available

NA

Description of how you validated changes

Manual testing, unit tests

Checklist

  • Have read the Pull Request Guidelines
  • PR description included
  • yarn test passes and tests are updated/added
  • PR title and commit messages follow conventional commit syntax
  • If this change should result in a version bump, changeset added (This can be done after creating the PR.) This does not apply to changes made to docs, e2e, examples, or other private packages.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

changeset-bot bot commented Oct 15, 2024

⚠️ No Changeset found

Latest commit: 5de62f0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@calebpollman calebpollman changed the title [WIP] feat(storage-browser): add useProcessTasks feat(storage-browser): add useProcessTasks Oct 15, 2024
@calebpollman calebpollman marked this pull request as ready for review October 15, 2024 23:59
@calebpollman calebpollman requested a review from a team as a code owner October 15, 2024 23:59
Copy link
Member

@AllanZhengYP AllanZhengYP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Only have 1 question.

branches: 81,
functions: 83,
lines: 91,
statements: 90,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

| 'FAILED'
| 'COMPLETE'
| 'QUEUED'
| 'PENDING';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between PENDING and QUEUED?

Copy link
Member Author

@calebpollman calebpollman Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • PENDING -> in progress/processing
  • QUEUED -> initial status, "not started"

Comment on lines +120 to +124
let count = 0;
while (count < concurrency) {
_processTasks(input);
count++;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The predicate here needs to be updated to compare the size of the inflight tasks to prevent spawning additional concurrent tasks on calls to processTasks while processing is active. Noting to be addressed in a follow up

isCancelable?: boolean;
}

export interface Task<T = any> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this any keep from leaking or do we have to keep it wide in order to allow any type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, needs to be wide for consumers to define the type of item. Providing any as the default generic allows for using Task in utils without specifying a type

cancel: undefined | (() => void);
item: T;
key: string;
message: string | undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be message?: string ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output values should not be optional unless defined by the consumer

})
.finally(() => {
inflight.current.delete(key);
_processTasks(input);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we end up in an infinite loop here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not unless i'm missing something, do you have a specific point of concern?

@calebpollman calebpollman merged commit 84f6d7c into feat-storage-browser/main Oct 16, 2024
38 checks passed
@calebpollman calebpollman deleted the feat-storage-browser/add-use-process-tasks branch October 16, 2024 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants