Skip to content

Add dialer-based RouteTaskHandler - #694

Open
gabotechs wants to merge 1 commit into
gabrielmusat/add-async-recursion-helpersfrom
gabrielmusat/add-dialer-based-route-task-handler
Open

Add dialer-based RouteTaskHandler#694
gabotechs wants to merge 1 commit into
gabrielmusat/add-async-recursion-helpersfrom
gabrielmusat/add-dialer-based-route-task-handler

Conversation

@gabotechs

@gabotechs gabotechs commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Rewrite of the task routing API that unlocks the door for implementing retries and smarter routing.

Key changes to the task-routing API:

Fire on a per-task basis instead of per-stage

Previously, this API was fired once for each stage, and the expected returns where a list of URLs (one per task in the stage):

Original ExecutionPlan + 3 tasks -> [URL1, URL2, URL3]

Now, this is called once per task, and the passed plan is the task specialized one, not the original one.

Task-specialized ExecutionPlan + task index -> URL1 + Stablished connection

Returns a successfully established connection

There was a problem with the previous task routing API:

It prompted users and/or default implementations to return a URL, without knowing if something is listening at the other side of the URL.

There is a chance that the routed machine is unavailable, in which case, the new API gives the option to implementations to retry on a different machine.

The event handler is now async

Connections must be established in this event handler, which means that it must make network calls, therefore it's now made async.

Introduction of CoordinatorToWorkerDialer

The CoordinatorToWorkerDialer is a trait that users are not supposed to implement, instead, they are supposed to call its .dial() method for attempting to establish a connection from coordinator to remote worker, so implementations of the RouteTaskHandler would look like this:

#[async_trait]
impl RouteTaskHandler for RandomRouteTaskHandler {
    async fn handle(&self, ev: RouteTaskEvent<'_>) -> Option<Result<RouteTaskEventResponse>> {
        // get a URL somehow
        
        Some(ev.dialer.dial(url.clone()).await)
    }
}

If there's an error while dialing the worker, the user can choose to retry on another URL.

The CoordinatorToWorkerDialer under the hood will handle all the API churn for making API calls to workers, leaving a clean and narrow API to the routing task event handler implementor, just requiring the URL to which it needs to connect to.

What's not included yet

Any kind of retry mechanism on a different node in case of a connection failure.


Stack created with GitHub Stacks CLIGive Feedback 💬

@gabotechs
gabotechs force-pushed the gabrielmusat/add-dialer-based-route-task-handler branch from 920687c to fdaa2f5 Compare September 4, 2026 09:28
@gabotechs
gabotechs force-pushed the gabrielmusat/add-dialer-based-route-task-handler branch from fdaa2f5 to 980ee25 Compare September 4, 2026 09:41

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@JSOD11 would love some feedback about the new shape of this API.

Base automatically changed from gabrielmusat/add-ok-or-some-err-macro to main September 5, 2026 15:33
@gabotechs
gabotechs force-pushed the gabrielmusat/add-dialer-based-route-task-handler branch from 980ee25 to 770ff5f Compare September 5, 2026 15:35
@gabotechs
gabotechs changed the base branch from main to gabrielmusat/add-async-recursion-helpers September 5, 2026 15:36
@gabotechs
gabotechs force-pushed the gabrielmusat/add-dialer-based-route-task-handler branch from 770ff5f to 903e262 Compare September 6, 2026 07:08
@gabotechs
gabotechs force-pushed the gabrielmusat/add-dialer-based-route-task-handler branch from 903e262 to 31748bc Compare September 6, 2026 17:00
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.

1 participant