nezha/model/server.go

28 lines
533 B
Go
Raw Normal View History

2019-12-08 10:18:29 -05:00
package model
2019-12-10 04:57:57 -05:00
import (
2020-12-08 21:27:00 -05:00
"fmt"
"html/template"
2020-10-24 09:29:05 -04:00
"time"
2020-11-10 21:07:45 -05:00
pb "github.com/naiba/nezha/proto"
2019-12-10 04:57:57 -05:00
)
2019-12-08 10:18:29 -05:00
// Server ..
type Server struct {
Common
Name string
2020-12-07 07:47:13 -05:00
Secret string `json:"-"`
2019-12-09 05:14:31 -05:00
Host *Host `gorm:"-"`
State *State `gorm:"-"`
2020-10-24 09:29:05 -04:00
LastActive time.Time
2019-12-10 04:57:57 -05:00
Stream pb.NezhaService_HeartbeatServer `gorm:"-" json:"-"`
StreamClose chan<- error `gorm:"-" json:"-"`
2019-12-08 10:18:29 -05:00
}
2020-12-08 21:27:00 -05:00
func (s Server) Marshal() template.JS {
return template.JS(fmt.Sprintf(`{"ID":%d,"Name":"%s","Secret":"%s"}`, s.ID, s.Name, s.Secret))
2020-12-08 21:27:00 -05:00
}