Improved healthcheck, idlewatcher support for loadbalanced routes, bug fixes

This commit is contained in:
yusing
2024-10-15 15:34:27 +08:00
parent 53fa28ae77
commit f4d532598c
34 changed files with 568 additions and 423 deletions

View File

@@ -0,0 +1,30 @@
package health
import (
"encoding/json"
"time"
"github.com/yusing/go-proxy/internal/net/types"
)
type JSONRepresentation struct {
Name string
Config *HealthCheckConfig
Status Status
Started time.Time
Uptime time.Duration
URL types.URL
Extra map[string]any
}
func (jsonRepr *JSONRepresentation) MarshalJSON() ([]byte, error) {
return json.Marshal(map[string]any{
"name": jsonRepr.Name,
"config": jsonRepr.Config,
"started": jsonRepr.Started.Unix(),
"status": jsonRepr.Status.String(),
"uptime": jsonRepr.Uptime.Seconds(),
"url": jsonRepr.URL.String(),
"extra": jsonRepr.Extra,
})
}