28 lines
1.0 KiB
Go
28 lines
1.0 KiB
Go
package system
|
|
|
|
import "sync/atomic"
|
|
|
|
// Info contains atomic counters and values for various server statistics
|
|
type Info struct {
|
|
App string `json:"app"`
|
|
Version string `json:"version"` // the current version of the server
|
|
Started int64 `json:"started"` // the time the server started in unix seconds
|
|
Time int64 `json:"time"` // current time on the server
|
|
Uptime int64 `json:"uptime"` // the number of seconds the server has been online
|
|
MemoryAlloc int64 `json:"memory_alloc"` // memory currently allocated
|
|
Threads int64 `json:"threads"` // number of active goroutines, named as threads for platform ambiguity
|
|
}
|
|
|
|
// Clone makes a copy of Info using atomic operation
|
|
func (i *Info) Clone() *Info {
|
|
return &Info{
|
|
App: "mysubarumq",
|
|
Version: i.Version,
|
|
Started: atomic.LoadInt64(&i.Started),
|
|
Time: atomic.LoadInt64(&i.Time),
|
|
Uptime: atomic.LoadInt64(&i.Uptime),
|
|
MemoryAlloc: atomic.LoadInt64(&i.MemoryAlloc),
|
|
Threads: atomic.LoadInt64(&i.Threads),
|
|
}
|
|
}
|