Skip to content

RFC: Effect Routing#514

Open
charypar wants to merge 15 commits intomasterfrom
viktor/effect-routing
Open

RFC: Effect Routing#514
charypar wants to merge 15 commits intomasterfrom
viktor/effect-routing

Conversation

@charypar
Copy link
Copy Markdown
Collaborator

@charypar charypar commented Apr 20, 2026

This is an RFC for a replacement for effect middleware, and a proof of concept test demonstrating how it would work. Not every detail is covered, but hopefully enough for feedback.

The more feedback the better!

@charypar
Copy link
Copy Markdown
Collaborator Author

@StuartHarris this hopefully matches our conversation a while back. It's turned out reasonably nice, other than having to deal with the annoying reference cycle between the core/router and the core-side effect handlers.

I've managed to keep the serialized FFI "lane" broadly the same, but an argument could be made that we should have one typed resolver per effect even in the serialized case and fully avoid the possibility of resolving effect A with a value for effect B.

@charypar charypar force-pushed the viktor/effect-routing branch from aaac2e7 to 1714053 Compare April 20, 2026 00:31
@charypar charypar marked this pull request as ready for review April 20, 2026 17:10
@StuartHarris StuartHarris force-pushed the viktor/effect-routing branch from 724e212 to e4c9767 Compare May 1, 2026 07:08
@charypar charypar force-pushed the viktor/effect-routing branch from e4c9767 to 06139f4 Compare May 3, 2026 13:49
@StuartHarris StuartHarris self-requested a review May 3, 2026 14:26
Copy link
Copy Markdown
Member

@StuartHarris StuartHarris left a comment

Choose a reason for hiding this comment

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

Let's do it!! ;-)

@charypar charypar force-pushed the viktor/effect-routing branch from db16127 to 6fb028e Compare May 3, 2026 18:06
Comment thread crux_core/tests/effect_router_prototype.rs
Comment thread crux_core/src/bridge/mod.rs Outdated
@charypar charypar force-pushed the viktor/effect-routing branch 3 times, most recently from 91fd979 to 777153a Compare May 3, 2026 18:41
@charypar charypar force-pushed the viktor/effect-routing branch from 777153a to 83a77a4 Compare May 5, 2026 17:12
@charypar
Copy link
Copy Markdown
Collaborator Author

charypar commented May 5, 2026

@StuartHarris I had a go at solving both of those problems by reifying the idea of lanes in code (I call them routes now). This both hides both the registry implementations (bridge one and new one), so we can change and optimise them how we like, and makes it impossible to resolve effects without running the effect pump.

Each route looks a bit like a core in its API, but it can be anything we find useful. The user is responsible for defining the route set, but we create it and give it the router weak ref. The dispatch function then gets the complete, ready to use route set, and the FFI can access it through the router.

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.

2 participants