Skip to content

Commit

Permalink
kes: fix uptime in status en/decoding
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
aead committed Feb 26, 2024
1 parent e40cf74 commit 0dfed1a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kes/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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,
Expand All @@ -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"`
Expand All @@ -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
Expand Down

0 comments on commit 0dfed1a

Please sign in to comment.