feat: ship loose-offline dbsync (validate, agent push, LWW audit)
Add UUID/FK channel checks, agent whitelist/push APIs, bindings, super-admin LWW audit with rollback, reconcile rate limits, and sync docs. Default customers stay opt-in; company conflict UI is removed. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"aijianzhan/platform/internal/config"
|
||||
"aijianzhan/platform/internal/handler"
|
||||
@@ -39,6 +40,34 @@ func main() {
|
||||
defer cancel()
|
||||
if ctx.DBSync != nil {
|
||||
ctx.DBSync.StartAll(runCtx)
|
||||
ttlDays := c.DBSync.LwwAuditTTLDays
|
||||
if ttlDays <= 0 {
|
||||
ttlDays = 90
|
||||
}
|
||||
go func() {
|
||||
t := time.NewTicker(6 * time.Hour)
|
||||
defer t.Stop()
|
||||
purge := func() {
|
||||
cutoff := time.Now().UTC().Add(-time.Duration(ttlDays) * 24 * time.Hour)
|
||||
n, err := ctx.DBSync.Store().PurgeLwwOverridesBefore(cutoff)
|
||||
if err != nil {
|
||||
fmt.Printf("dbsync lww purge: %v\n", err)
|
||||
return
|
||||
}
|
||||
if n > 0 {
|
||||
fmt.Printf("dbsync lww purge: removed %d\n", n)
|
||||
}
|
||||
}
|
||||
purge()
|
||||
for {
|
||||
select {
|
||||
case <-runCtx.Done():
|
||||
return
|
||||
case <-t.C:
|
||||
purge()
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
||||
Reference in New Issue
Block a user