feat(katana-tasks): task manager - #2318
Conversation
WalkthroughOhayo, sensei! The recent changes enhance the asynchronous task management capabilities of the application. Key updates include upgrading the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant TaskManager
participant TaskBuilder
participant CriticalTaskBuilder
User->>TaskManager: Request to spawn task
TaskManager->>TaskBuilder: Create new task
TaskBuilder->>TaskManager: Configure task parameters
TaskManager->>TaskManager: Spawn task
TaskManager->>User: Task is active
User->>TaskManager: Request cancellation
TaskManager->>TaskManager: Handle cancellation
TaskManager->>User: Task cancelled or completed
sequenceDiagram
participant User
participant CriticalTaskBuilder
User->>CriticalTaskBuilder: Request to spawn critical task
CriticalTaskBuilder->>CriticalTaskBuilder: Configure critical parameters
CriticalTaskBuilder->>User: Task is now running
User->>CriticalTaskBuilder: Await completion or cancellation
CriticalTaskBuilder->>User: Task completed or error handled
Recent review detailsConfiguration used: .coderabbit.yaml Files ignored due to path filters (1)
Files selected for processing (5)
Additional comments not posted (8)
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2318 +/- ##
==========================================
+ Coverage 66.18% 67.31% +1.13%
==========================================
Files 352 354 +2
Lines 46739 46433 -306
==========================================
+ Hits 30933 31258 +325
+ Misses 15806 15175 -631 ☔ View full report in Codecov by Sentry. |
glihm
left a comment
There was a problem hiding this comment.
Maybe not for now, but wondering at which point this could be re-used by different part of the stack, and not only Katana. :)
As this concept of having critical tasks auto-cancelling others for a graceful shutdown can actually be handy for long running processes like Torii or even Sozo could leverage that using multitasking for speeding up the migration process.
yeah agree i think this component is generic enough to be used outside the scope of katana. would be useful for something like torii that has to manage a bunch of async tasks at the same time. we should definitely use this (or a variation of it) in torii. this PR doesn't include integration into katana itself but i think implementing the task manger now would be helpful just to move katana bit by bit around the task management abstraction. if i am to integrate it now there would only be 1 task (ie node service) running inside the manager. something that i need to do is to separate the node service task into smaller individual tasks ie block production and messaging. later on the servers stuff should ideally be spawned in the manager as well. |
introduce a
TaskManagerstruct to manage tasks that can be instrumented and cancelled for graceful shutdown. there is also a task builder associated with the task manager where a task can be configured to be:the idea is to spawn all main (critical) tasks (ie block production, messaging, servers, ... ) and be able to cancel the tasks for graceful shutdown (eg when a main task panicked).
Summary by CodeRabbit
New Features
TaskManagerfor efficient management and cancellation of asynchronous tasks.TaskBuilderandCriticalTaskBuilderfor flexible task configuration and error handling.Bug Fixes
Tests