iot_server/internal/models/servicestats.go

43 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//
// Copyright (C) 2021 IOTech Ltd
//
// SPDX-License-Identifier: Apache-2.0
package models
import (
"encoding/json"
)
// 服务类型,服务,驱动
const (
ServiceTypeEnumService = "service"
ServiceTypeEnumDriver = "driver"
ServiceTypeEnumThirdPartApp = "appService"
)
// 使用 redis hash 存储name 做 field
type ServiceStats struct {
Id string `gorm:"column:id" json:"id"` // 服务标识
Name string `gorm:"column:name;pk" json:"name"` // 容器名称
LogPath string `json:"log_path"` // 日志地址, 宿主主机日志路径
ServiceType string `json:"service_type"` // 服务类型,服务,驱动,应用
Healthy bool `json:"healthy"` // 状态, docker.inspect.State.Running
Created string `json:"created"` // 创建时间, docker.inspect.Created
Started string `json:"started"` // 启动时间, docker.inspect.State.StartedAt
}
func (s ServiceStats) ToJSON() string {
body, _ := json.Marshal(s)
return string(body)
}
func (s *ServiceStats) TableName() string {
return "service_stats"
}
func (s *ServiceStats) Get() interface{} {
return *s
}