mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-05 13:10:07 +00:00
⚡️ 提升「服务」页面抗击打能力
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/hashicorp/go-uuid"
|
||||
"github.com/jinzhu/copier"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"golang.org/x/sync/singleflight"
|
||||
|
||||
@@ -100,12 +101,22 @@ func (p *commonPage) checkViewPassword(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (p *commonPage) service(c *gin.Context) {
|
||||
singleton.AlertsLock.RLock()
|
||||
defer singleton.AlertsLock.RUnlock()
|
||||
res, _, _ := p.requestGroup.Do("servicePage", func() (interface{}, error) {
|
||||
singleton.AlertsLock.RLock()
|
||||
defer singleton.AlertsLock.RUnlock()
|
||||
var stats map[uint64]model.ServiceItemResponse
|
||||
var statsStore map[uint64]model.CycleTransferStats
|
||||
copier.Copy(&stats, singleton.ServiceSentinelShared.LoadStats())
|
||||
copier.Copy(&statsStore, singleton.AlertsCycleTransferStatsStore)
|
||||
return []interface {
|
||||
}{
|
||||
stats, statsStore,
|
||||
}, nil
|
||||
})
|
||||
c.HTML(http.StatusOK, "theme-"+singleton.Conf.Site.Theme+"/service", mygin.CommonEnvironment(c, gin.H{
|
||||
"Title": "服务状态",
|
||||
"Services": singleton.ServiceSentinelShared.LoadStats(),
|
||||
"CycleTransferStats": singleton.AlertsCycleTransferStatsStore,
|
||||
"Services": res.([]interface{})[0],
|
||||
"CycleTransferStats": res.([]interface{})[1],
|
||||
"CustomCode": singleton.Conf.Site.CustomCode,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
func main() {
|
||||
c := cron.New(cron.WithSeconds())
|
||||
_, err := c.AddFunc("* * * * * *", func() {
|
||||
log.Println("bingo second")
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
_, err = c.AddFunc("* * * * *", func() {
|
||||
log.Println("bingo minute")
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
c.Start()
|
||||
select {}
|
||||
type Cat struct {
|
||||
age int
|
||||
name string
|
||||
friends []string
|
||||
}
|
||||
|
||||
func main() {
|
||||
a := Cat{7, "Wilson", []string{"Tom", "Tabata", "Willie"}}
|
||||
b := Cat{7, "Wilson", []string{"Tom", "Tabata", "Willie"}}
|
||||
c := Cat{7, "Wilson", []string{"Tom", "Tabata", "Willie"}}
|
||||
wilson := []*Cat{&a, &b, &c}
|
||||
nikita := []Cat{}
|
||||
copier.Copy(&nikita, &wilson)
|
||||
|
||||
nikita[0].friends = append(nikita[0].friends, "Syd")
|
||||
|
||||
fmt.Println(wilson[0])
|
||||
fmt.Println(nikita[0])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user