Repository navigation
feat: Introduce MultiIsolateRelicServer - #216
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughIntroduces lazy IOAdapter initialization via an adapter factory, adds Adapter.port, adds IsolatedObject for cross‑isolate RPC and multi‑isolate RelicServer implementations, and updates examples and tests to use the new factory and multi‑isolate patterns. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Caller/Test
participant Server as RelicServer
participant Factory as AdapterFactory
participant Adapter as IOAdapter
participant Isolated as IsolatedObject
participant Child as ChildIsolate
rect #DCEFFD
Note over Caller,Server: Old (Eager)
Caller->>Adapter: IOAdapter.bind()
Adapter-->>Server: adapter instance
Caller->>Server: RelicServer(adapter)
end
rect #DFFFD9
Note over Caller,Server: New (Lazy)
Caller->>Server: RelicServer(() => IOAdapter.bind())
Server->>Server: store adapterFactory
Caller->>Server: mountAndStart(handler)
Server->>Factory: call adapterFactory()
Factory-->>Adapter: bind -> adapter + port
Adapter-->>Server: adapter ready
Server->>Server: start serving
end
rect #FFEFD9
Note over Server,Isolated: Multi‑isolate (noOfIsolates > 1)
Server->>Isolated: IsolatedObject(adapterFactory)
Isolated->>Child: spawn isolate & handshake
Child->>Factory: call adapterFactory()
Factory-->>Adapter: bind -> adapter + port
Child-->>Isolated: send port & ready
Isolated-->>Server: propagate port
Server->>Isolated: evaluate(fn)
Isolated->>Child: dispatch {id, fn}
Child->>Child: execute fn(isolatedObject)
Child-->>Isolated: respond {id, result}
Isolated-->>Server: deliver result
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #216 +/- ##
==========================================
+ Coverage 91.23% 91.33% +0.10%
==========================================
Files 88 89 +1
Lines 3343 3428 +85
Branches 1720 1763 +43
==========================================
+ Hits 3050 3131 +81
- Misses 293 297 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5949364 to
d5f5a42
Compare
41036e3 to
e1038a8
Compare
2ac3ae2 to
ced8324
Compare
ced8324 to
88b228e
Compare
5d4d3b0 to
229f794
Compare
08dd9d0 to
62e0521
Compare
|
Rebased |
Previously `evaluate` would hang forever. test: Add tons of tests for `IsolatedObject`. Coverage of this class is now 94.3%. Only "impossible" lines are not covered. refactor!: Drop special `evaluateVoid`. Just use `evaluate`. This was an easy error to make, and it can handled gracefully with `FutureOr<U>`.
Moved IsolatedObject.close related tests to isolated_object_close_test.dart
62e0521 to
237d20d
Compare
Description
RelicServerto enable concurrent request handling across multiple CPU cores.RelicServerinto a sealed interface with the existing implementation moved to_RelicServer.IsolatedObject<T>, a generic wrapper that spawns an object in a separate isolate and communicates via message passing._IsolatedRelicServerand_MultiIsolateRelicServerimplementations ofRelicServer.noOfIsolatesoptional named parameter toRelicServerconstructor (which is now a factory, delegating to either _RelicServer or _MultiIsolateRelicServer), andRelicApp.run.Related Issues
Pre-Launch Checklist
Please ensure that your PR meets the following requirements before submitting:
///), ensuring consistency with existing project documentation.Breaking Changes
Additional Notes
The
IsolatedObjectimplementation handles error propagation viaRemoteErrorand proper cleanup of ports and subscriptions.Summary by CodeRabbit
New Features
Breaking Changes
Tests
Docs