Skip to content

Commit

Permalink
chore: update runtime info add running at
Browse files Browse the repository at this point in the history
  • Loading branch information
whatwewant committed Jul 19, 2024
1 parent 16c06ad commit 6601fc5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions components/application/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
// Runtime ...
type Runtime interface {
CurrentTime() *datetime.DateTime
RunningAt() *datetime.DateTime
OS() string
Arch() string
CPUCores() int
Expand All @@ -33,24 +34,32 @@ type Info struct {
MemoryTotal uint64 `json:"memory_total"`
DiskUsed float64 `json:"disk_used"`
DiskTotal float64 `json:"disk_total"`
Timestamp string `json:"current_time"`
CurrentTime string `json:"current_time"`
RunningAt string `json:"running_at"`
}

type runtime struct {
logger *logger.Logger

runningAt *datetime.DateTime
}

// New ...
func New(logger *logger.Logger) Runtime {
return &runtime{
logger: logger,
logger: logger,
runningAt: datetime.Now(),
}
}

func (r *runtime) CurrentTime() *datetime.DateTime {
return datetime.Now()
}

func (r *runtime) RunningAt() *datetime.DateTime {
return r.runningAt
}

func (r *runtime) OS() string {
return rt.GOOS
}
Expand Down Expand Up @@ -105,7 +114,8 @@ func (r *runtime) Info() *Info {
MemoryTotal: memTotal,
DiskUsed: diskTotal - diskFree,
DiskTotal: diskTotal,
Timestamp: r.CurrentTime().Format("YYYY-MM-DD HH:mm:ss"),
CurrentTime: r.CurrentTime().Format("YYYY-MM-DD HH:mm:ss"),
RunningAt: r.runningAt.Format("YYYY-MM-DD HH:mm:ss"),
}
}

Expand Down

0 comments on commit 6601fc5

Please sign in to comment.