fix: 仅向已握手连接推送并拆分调度循环
This commit is contained in:
@@ -90,10 +90,16 @@ type App struct {
|
||||
met *metrics.Registry
|
||||
|
||||
mu sync.Mutex
|
||||
largeSem chan struct{}
|
||||
largeHeld map[string]bool
|
||||
pendingRevoke []revokeJob
|
||||
repushTimers map[string]*time.Timer
|
||||
workers map[string]*pushWorker
|
||||
handshook map[string]port.ConnID
|
||||
rcptInflight map[string]map[int64]int64 // connID → receiptID → 推送时刻 ms
|
||||
|
||||
dispatchCh chan struct{}
|
||||
loopWG sync.WaitGroup
|
||||
lastPurge time.Time
|
||||
purgeMu sync.Mutex
|
||||
}
|
||||
|
||||
// Option 配置 App。
|
||||
@@ -142,13 +148,15 @@ func New(db *store.DB, lim Limits, hash auth.HashPool, opts ...Option) *App {
|
||||
lim.GraceSeconds = 60
|
||||
}
|
||||
a := &App{
|
||||
db: db,
|
||||
lim: lim,
|
||||
hash: hash,
|
||||
nowFn: time.Now,
|
||||
rates: newRateLimiter(lim.RequestsPerSecond, lim.RequestBurst),
|
||||
largeSem: make(chan struct{}, maxLargeInflight),
|
||||
largeHeld: make(map[string]bool),
|
||||
db: db,
|
||||
lim: lim,
|
||||
hash: hash,
|
||||
nowFn: time.Now,
|
||||
rates: newRateLimiter(lim.RequestsPerSecond, lim.RequestBurst),
|
||||
workers: make(map[string]*pushWorker),
|
||||
handshook: make(map[string]port.ConnID),
|
||||
rcptInflight: make(map[string]map[int64]int64),
|
||||
dispatchCh: make(chan struct{}, 1),
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(a)
|
||||
|
||||
Reference in New Issue
Block a user