GoDoxy/internal/metrics/uptime/status.go
Yuzerion 80bc018a7f
feat: custom json marshaling implementation, replace json and yaml library (#89)
* chore: replace gopkg.in/yaml.v3 vs goccy/go-yaml; replace encoding/json with bytedance/sonic

* fix: yaml unmarshal panic

* feat: custom json marshaler implementation

* chore: fix import and err marshal handling

---------

Co-authored-by: yusing <yusing@6uo.me>
2025-04-16 15:02:11 +08:00

22 lines
385 B
Go

package uptime
import (
"fmt"
"github.com/yusing/go-proxy/internal/watcher/health"
)
type Status struct {
Status health.Status
Latency int64
Timestamp int64
}
type RouteStatuses map[string][]*Status
func (s *Status) MarshalJSONTo(buf []byte) []byte {
return fmt.Appendf(buf,
`{"status":"%s","latency":"%d","timestamp":"%d"}`,
s.Status, s.Latency, s.Timestamp,
)
}