mirror of
https://github.com/luckjiawei/podux.git
synced 2026-11-30 00:56:47 +00:00
35 lines
844 B
Go
35 lines
844 B
Go
package server
|
|
|
|
import (
|
|
serverdomain "frpc-hub/internal/domain/server"
|
|
|
|
"github.com/pocketbase/pocketbase/core"
|
|
)
|
|
|
|
type Service struct {
|
|
app core.App
|
|
repo serverdomain.Repository
|
|
}
|
|
|
|
func NewService(app core.App, repo serverdomain.Repository) *Service {
|
|
return &Service{app: app, repo: repo}
|
|
}
|
|
|
|
func (s *Service) GetServerCountByStatus(status serverdomain.ServerStatus) (int64, error) {
|
|
return s.repo.CountByBootStatus(status)
|
|
}
|
|
|
|
func (s *Service) UpdateServerBootStatus(serverID string, status serverdomain.ServerStatus) error {
|
|
return s.repo.UpdateBootStatus(serverID, status)
|
|
}
|
|
|
|
func (s *Service) ResetAllServerStatus() {
|
|
if err := s.repo.ResetAllBootStatus(); err != nil {
|
|
s.app.Logger().Error("ResetAllServerStatus failed", "error", err)
|
|
}
|
|
}
|
|
|
|
func (s *Service) GetMaxLatency() (int64, error) {
|
|
return s.repo.GetMaxLatency()
|
|
}
|