From d403bbfbf272ed5133e8574257b8306f0b38a10f Mon Sep 17 00:00:00 2001 From: Andreas Auernhammer Date: Mon, 26 Feb 2024 13:59:15 +0100 Subject: [PATCH] kes: fix uptime in status en/decoding This commit fixes a display bug in the server status en/decoding. The server returns its uptime in seconds. With this commit, the client parses a server response correctly. Signed-off-by: Andreas Auernhammer --- kes/api.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kes/api.go b/kes/api.go index 9c186f0..7c1976b 100644 --- a/kes/api.go +++ b/kes/api.go @@ -33,7 +33,7 @@ func (s State) MarshalJSON() ([]byte, error) { Version string `json:"version,omitempty"` OS string `json:"os,omitempty"` Arch string `json:"arch,omitempty"` - UpTime time.Duration `json:"uptime,omitempty"` + UpTime float64 `json:"uptime,omitempty"` CPUs int `json:"num_cpu,omitempty"` UsableCPUs int `json:"num_cpu_used,omitempty"` HeapAlloc uint64 `json:"mem_heap_used,omitempty"` @@ -55,7 +55,7 @@ func (s State) MarshalJSON() ([]byte, error) { Version: s.Version, OS: s.OS, Arch: s.Arch, - UpTime: s.UpTime, + UpTime: s.UpTime.Round(time.Second).Seconds(), CPUs: s.CPUs, UsableCPUs: s.UsableCPUs, HeapAlloc: s.HeapAlloc, @@ -72,7 +72,7 @@ func (s *State) UnmarshalJSON(data []byte) error { Version string `json:"version"` OS string `json:"os"` Arch string `json:"arch"` - UpTime time.Duration `json:"uptime"` + UpTime float64 `json:"uptime"` CPUs int `json:"num_cpu"` UsableCPUs int `json:"num_cpu_used"` HeapAlloc uint64 `json:"mem_heap_used"` @@ -99,7 +99,7 @@ func (s *State) UnmarshalJSON(data []byte) error { s.Version = v.Version s.OS = v.OS s.Arch = v.Arch - s.UpTime = v.UpTime + s.UpTime = time.Duration(v.UpTime * float64(time.Second)) s.CPUs = v.CPUs s.UsableCPUs = v.UsableCPUs s.HeapAlloc = v.HeapAlloc