feat(auth): enhance watcher with asynchronous dispatch and buffering

- Added async dispatch loop to `Watcher` for handling incremental `AuthUpdate` with in-memory buffering.
- Improved resilience against high-frequency auth changes by coalescing updates and reducing redundant processing.
- Updated `cliproxy` service to increase auth update queue capacity and optimize backlog consumption.
- Added detailed SDK integration documentation in English and Chinese (`sdk-watcher.md`, `sdk-watcher_CN.md`).
This commit is contained in:
Luis Pater
2025-09-23 04:33:48 +08:00
parent 792ec49e5b
commit 6046a8c95b
4 changed files with 195 additions and 6 deletions

View File

@@ -78,7 +78,7 @@ func (s *Service) ensureAuthUpdateQueue(ctx context.Context) {
return
}
if s.authUpdates == nil {
s.authUpdates = make(chan watcher.AuthUpdate, 64)
s.authUpdates = make(chan watcher.AuthUpdate, 256)
}
if s.authQueueStop != nil {
return
@@ -98,6 +98,14 @@ func (s *Service) consumeAuthUpdates(ctx context.Context) {
return
}
s.handleAuthUpdate(ctx, update)
for {
select {
case nextUpdate := <-s.authUpdates:
s.handleAuthUpdate(ctx, nextUpdate)
default:
break
}
}
}
}
}