refactor(route): unify common fields into routes.go

This commit is contained in:
yusing
2025-06-05 18:25:15 +08:00
parent d3568d9c35
commit 9470a14fe8
4 changed files with 15 additions and 68 deletions

View File

@@ -11,20 +11,14 @@ import (
net "github.com/yusing/go-proxy/internal/net/types"
"github.com/yusing/go-proxy/internal/route/routes"
"github.com/yusing/go-proxy/internal/task"
"github.com/yusing/go-proxy/internal/watcher/health"
"github.com/yusing/go-proxy/internal/watcher/health/monitor"
)
// TODO: support stream load balance.
type StreamRoute struct {
*Route
net.Stream `json:"-"`
HealthMon health.HealthMonitor `json:"health"`
task *task.Task
l zerolog.Logger
}
@@ -88,20 +82,6 @@ func (r *StreamRoute) Start(parent task.Parent) gperr.Error {
return nil
}
// Task implements task.TaskStarter.
func (r *StreamRoute) Task() *task.Task {
return r.task
}
// Finish implements task.TaskFinisher.
func (r *StreamRoute) Finish(reason any) {
r.task.Finish(reason)
}
func (r *StreamRoute) HealthMonitor() health.HealthMonitor {
return r.HealthMon
}
func (r *StreamRoute) acceptConnections() {
defer r.task.Finish("listener closed")