refactor: cleanup server/runner - #287
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors Runner.Run() to make the startup/shutdown flow easier to follow by extracting cohesive helper functions and consolidating cleanup into a single deferred shutdown block.
Changes:
- Refactored
Runner.Run()into a more linear sequence with helper funcs for tracer init, pool loading, flow construction, health server init, metrics server start, inference client init, and transform loading. - Centralized shutdown/cleanup (health server, gate factory, tracer) into one deferred block that consistently runs on all exit paths.
- Improved a few error returns (notably wrapping TLS build errors and transform config/chain errors with
%w).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The refactor dropped the setupLog.Error(...) logs from loadWorkerPools, loadFlow, initInferenceClient (TLS), and defer func() { Nits (non-blocking): loadTransforms should take ctx first; naked return → return nil; the new pure helpers (loadFlow, loadWorkerPools) are worth a quick unit test. The pool not found removal is fine — the merge policy already panics on an unknown pool. |
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
eb62c01 to
b99a773
Compare
What does this PR do?
Refactor Runner.Run() so that the logic is more straightforward: move some code to sibling funcs, refactor to a unified defer block, share the same context where possible.
Why is this change needed?
Runner.Run() is hard to understand and would benefit from a light refactoring, before we move more pieces around.
How was this tested?
All tests should still pass.
Checklist
git commit -s) per DCOmake test)make lint)Related Issues
follow up to #283, related to #284