backend: refactor StartHeadlampServer by extracting runServer - #6217
Conversation
illume
left a comment
There was a problem hiding this comment.
Thanks for these changes.
Can you please have a look at the git commits to see if they meet the contribution guidelines? We use a Linux kernel style of git commits. See the contributing guide for general context, and please see previous git commits with git log for examples.
Commits that need attention
backend: Extract runServer from StartHeadlampServer, drop nolint:funlen— Only one file changed insidebackend/; add a sub-area so it's clear what was touched (e.g.backend: ComponentName: description).
Commit guidelines
- Use atomic commits focused on a single change.
- Use the title format
<area>: <Description of changes>— description must start with a capital letter. - Keep the title under 72 characters (soft requirement).
- Explain the intention and why the change is needed.
- Make commit titles meaningful and describe what changed.
- Do not add code that a later commit rewrites; squash or reorder commits instead.
- Do not include
Fixes #NNin commit messages.
Good examples:
frontend: HomeButton: Fix so it navigates to homebackend: config: Add enable-dynamic-clusters flag
There was a problem hiding this comment.
Pull request overview
This PR refactors the backend server startup path by extracting the HTTP server lifecycle (listen + graceful shutdown + error handling) from StartHeadlampServer into a new unexported helper, runServer, to improve readability and remove the //nolint:funlen suppression without changing behavior.
Changes:
- Removed the
//nolint:funlensuppression onStartHeadlampServerby extracting the server lifecycle logic. - Added
runServer(config, cancel, handler)to encapsulate server creation, ListenAndServe(TLS), graceful shutdown wiring, and startup error handling.
Extract server creation, graceful shutdown, TLS/plain listening, and error handling from StartHeadlampServer into a new runServer helper. StartHeadlampServer now focuses on setup (telemetry, router, static files, handler assembly). The server lifecycle concern is entirely in runServer, which accepts the config, cancel func, and handler. Removes the //nolint:funlen annotation — both functions are now within the funlen limit.
7ec9166 to
01a760b
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: illume, srajang1805 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary
This PR refactors
StartHeadlampServerby extracting the server startup and shutdown logic into a dedicatedrunServerhelper.The extraction removes the existing
//nolint:funlensuppression while preserving the original behavior.StartHeadlampServernow focuses on orchestration, with the server lifecycle encapsulated in a smaller helper.Changes
Extracted
runServer(config, cancel, handler)fromStartHeadlampServer.Moved:
Removed the
//nolint:funlensuppression fromStartHeadlampServer.No functional changes or API changes.
Advantages
//nolint:funlensuppression.StartHeadlampServereasier to read and maintain.Verification
Notes for Reviewers
runServer.//nolint:funlensuppression.