syncLoop 同步循环
(ctx context.Context)
| 183 | |
| 184 | // syncLoop 同步循环 |
| 185 | func (i *AGUIInterface) syncLoop(ctx context.Context) { |
| 186 | ticker := time.NewTicker(i.opts.SyncInterval) |
| 187 | defer ticker.Stop() |
| 188 | |
| 189 | for { |
| 190 | select { |
| 191 | case <-ctx.Done(): |
| 192 | return |
| 193 | case <-ticker.C: |
| 194 | if err := i.syncAll(); err != nil { |
| 195 | if i.opts.EnableLogging { |
| 196 | fmt.Printf(" [AGUI] Sync error: %v\n", err) |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | // syncAll 同步所有资源 |
| 204 | func (i *AGUIInterface) syncAll() error { |