Skip to content

Various refactoring for dynamic worker loading#4360

Merged
kentonv merged 6 commits intomainfrom
kenton/refactoring-for-dynamic-isolates
Jun 18, 2025
Merged

Various refactoring for dynamic worker loading#4360
kentonv merged 6 commits intomainfrom
kenton/refactoring-for-dynamic-isolates

Conversation

@kentonv
Copy link
Member

@kentonv kentonv commented Jun 17, 2025

This is just some simple refactoring needed for my upcoming dynamic worker loading feature. Figured I'd put these up and get them merged before conflicts arise (especially the first commit, which moves a bunch of code).

kentonv added 3 commits June 17, 2025 15:52
All of `WorkerSource` except its last few lines are a pure cut-and-paste from Worker::Script.

This is needed so that we can use `WorkerSource` in io-channels.h to define a dynamic isolate channel. io-channels.h cannot include worker.h as this would be a cyclic dependency.
The current version assumes flags always originate in capnp, but dynamic isolates will want to specify them, well, dynamically.
Similar to #4082, we want the representation of the worker definition passed to `makeWorker()` to not have to come from a workerd config file. This introduces an intermediate representation, `WorkerDef`, to represent this.

No logic has changed here, code has just moved around.
@kentonv kentonv requested a review from anonrig June 17, 2025 23:09
@kentonv kentonv requested review from a team as code owners June 17, 2025 23:09
kentonv added 3 commits June 17, 2025 20:10
This will be needed as the dynamic isolate API can pass other kinds of Frakenvalues.
Much of ErrorReporter will be shared with dynamic isolates, but the way errors themselves are reported needs to be different. This introduces a new type `ConfigErrorReporter` for the specific purpose of top-level workerd config errors.
The link callback for WorkerServices was reporting errors directly using `reportConfigError()` but this will not be appropriate for dynamically-loaded services.
@kentonv kentonv force-pushed the kenton/refactoring-for-dynamic-isolates branch from e26c3d1 to 91964a4 Compare June 18, 2025 01:10
@kentonv kentonv merged commit 0a2665a into main Jun 18, 2025
20 of 21 checks passed
@kentonv kentonv deleted the kenton/refactoring-for-dynamic-isolates branch June 18, 2025 14:02
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