Skip to content

refactor(server): remove Run/Option, use Start/Done/Wait/Shutdown#413

Open
wc4440222 wants to merge 1 commit into
ccfos:mainfrom
wc4440222:refactor/server-remove-run-use-start
Open

refactor(server): remove Run/Option, use Start/Done/Wait/Shutdown#413
wc4440222 wants to merge 1 commit into
ccfos:mainfrom
wc4440222:refactor/server-remove-run-use-start

Conversation

@wc4440222

Copy link
Copy Markdown
Contributor

Summary

Per @hao022 feedback on #311, this PR removes the legacy Run function and Option type from internal/server, aligning huatuo-bamai with the same Start → Done/Wait → Shutdown pattern used by huatuo-apiserver.

Changes

internal/server/server.go

  • Remove Run, run, and Option type
  • Remove unused backoff and syscall imports

cmd/huatuo-bamai/handlers/server.go

  • Start now returns (RunningServer, error) instead of nothing
  • Uses httpServer.Start(opts.Addr) instead of s.Run(&Option{...})
  • Remove EnableRetry from config (no longer needed)
  • Add RunningServer interface (matching apiserver pattern)

cmd/huatuo-bamai/tracing.go

  • startHandlers saves the returned RunningServer to d.apiServer
  • Registers runningServer.Shutdown as daemon cleanup

cmd/huatuo-bamai/main.go

  • Add apiServer field to Daemon struct
  • waitForSignal now monitors apiServer.Done() for unexpected exits
  • Returns (os.Signal, error) to propagate serve errors

Reference

This follows the pattern in cmd/huatuo-apiserver/ where:

  1. handlers.Start returns (RunningServer, error)
  2. startHandlers saves the server and registers Shutdown as cleanup
  3. Daemon.waitForSignal monitors server.Done()

Per hao022 feedback on ccfos#311, remove the legacy Run function and
Option type from internal/server. Align huatuo-bamai with the
same Start -> Done/Wait -> Shutdown pattern used by huatuo-apiserver.

Changes:
- handlers.Start returns (RunningServer, error) using httpServer.Start
- startHandlers saves the returned server and registers Shutdown as
  cleanup
- Daemon monitors apiServer.Done() for unexpected exits
- Remove Run, run, and Option from internal/server
- Remove unused backoff and syscall imports

Signed-off-by: wc4440222 <[email protected]>
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.

1 participant