nezha/model/server.go

27 lines
475 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"
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
2020-10-24 09:29:05 -04:00
Host *Host
State *State
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() string {
return fmt.Sprintf(`{"ID":%d,"Name":"%s","Secret":"%s"}`, s.ID, s.Name, s.Secret)
}