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

Allow TreeWalkerSession to call WalkTree multiple times #19

Open
TravisOnGit opened this issue Jun 25, 2020 · 0 comments
Open

Allow TreeWalkerSession to call WalkTree multiple times #19

TravisOnGit opened this issue Jun 25, 2020 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@TravisOnGit
Copy link
Member

Today a TreeWalkerSession can only call WalkTree one time. This is because the internal CancellationTokenSource (walkTreeCts) is created in the constructor, and cancelled at the end of WalkTree to make sure all tasks get cleaned up.

However, there is a common pattern to intentionally halt the tree walker by throwing an exception. The application then retries walking the tree at a later time depending on the scenario.

  • E.g. Halt tree walker in BeforeVisitNode due to hitting a rate limit, then retry walking the tree in 1 minute.
  • E.g. Halt tree walker to wait for an event, then walk the tree again.

The issue is because TreeWalkerSession can only call WalkTree once, the application must initialize a new TreeWalkerSession for every retry attempt. Even though all the same parameters are often used. Being able to use the original TreeWalkerSession would simplify and optimize the multi-WalkTree scenarios.

Solution idea:

  • Recreate the walkTreeCts at the top of WalkTree. This would allow WalkTree to be called multiple times.
  • Before recreating walkTreeCts in WalkTree, consider if we should cancel and dispose the existing walkTreeCts.
  • We also need to keep the initialize walkTreeCts in the constructor since some applications call VisitNode instead of WalkTree, and we don't want to break them.
  • Unrelated, but we should also call walkTreeCts.Dispose() after calling Cancel() in the CancelWalkTree() method.
@TravisOnGit TravisOnGit added enhancement New feature or request good first issue Good for newcomers labels Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant