-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
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.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers