add hook for handler
change map to cmap for Trigger.hashs
This commit is contained in:
Yuzuki616
2024-10-30 01:07:17 +09:00
parent 3ff99d4fd1
commit ffcbec4ede
8 changed files with 75 additions and 10 deletions

View File

@@ -17,13 +17,13 @@ func (t *Trigger) addCronHandle(cron any, job cron.FuncJob) (cron.EntryID, error
}
func (t *Trigger) hashEqualsOrStore(name, hash string) bool {
if h, ok := t.hashs[name]; ok {
if h, ok := t.hashs.Get(name); ok {
if h == hash {
return true
}
t.hashs[name] = hash
t.hashs.Set(name, hash)
} else {
t.hashs[name] = hash
t.hashs.Set(name, hash)
}
return false
}

View File

@@ -5,6 +5,7 @@ import (
"Ratte/handler"
"fmt"
"github.com/Yuzuki616/Ratte-Interface/panel"
cmap "github.com/orcaman/concurrent-map/v2"
"github.com/robfig/cron/v3"
"github.com/sirupsen/logrus"
)
@@ -16,7 +17,7 @@ type Trigger struct {
p panel.Panel
remoteId int
remoteC *conf.Remote
hashs map[string]string
hashs cmap.ConcurrentMap[string, string]
}
func NewTrigger(