mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-30 06:51:30 +02:00
use base context for manager calls
This commit is contained in:
parent
27b3a39f2b
commit
6965bfbf6c
1 changed files with 8 additions and 6 deletions
|
@ -9,6 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type updateUserInfoScheduler struct {
|
type updateUserInfoScheduler struct {
|
||||||
|
baseCtx context.Context
|
||||||
updateUserInfoInterval time.Duration
|
updateUserInfoInterval time.Duration
|
||||||
updateUserInfo func(ctx context.Context, userID string)
|
updateUserInfo func(ctx context.Context, userID string)
|
||||||
userID string
|
userID string
|
||||||
|
@ -24,13 +25,13 @@ func newUpdateUserInfoScheduler(
|
||||||
userID string,
|
userID string,
|
||||||
) *updateUserInfoScheduler {
|
) *updateUserInfoScheduler {
|
||||||
uuis := &updateUserInfoScheduler{
|
uuis := &updateUserInfoScheduler{
|
||||||
|
baseCtx: ctx,
|
||||||
updateUserInfoInterval: updateUserInfoInterval,
|
updateUserInfoInterval: updateUserInfoInterval,
|
||||||
updateUserInfo: updateUserInfo,
|
updateUserInfo: updateUserInfo,
|
||||||
userID: userID,
|
userID: userID,
|
||||||
reset: make(chan struct{}, 1),
|
reset: make(chan struct{}, 1),
|
||||||
}
|
}
|
||||||
ctx = context.WithoutCancel(ctx)
|
ctx, uuis.cancel = context.WithCancel(context.WithoutCancel(uuis.baseCtx))
|
||||||
ctx, uuis.cancel = context.WithCancel(ctx)
|
|
||||||
go uuis.run(ctx)
|
go uuis.run(ctx)
|
||||||
return uuis
|
return uuis
|
||||||
}
|
}
|
||||||
|
@ -57,12 +58,13 @@ func (uuis *updateUserInfoScheduler) run(ctx context.Context) {
|
||||||
case <-uuis.reset:
|
case <-uuis.reset:
|
||||||
ticker.Reset(uuis.updateUserInfoInterval)
|
ticker.Reset(uuis.updateUserInfoInterval)
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
uuis.updateUserInfo(ctx, uuis.userID)
|
uuis.updateUserInfo(uuis.baseCtx, uuis.userID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type refreshSessionScheduler struct {
|
type refreshSessionScheduler struct {
|
||||||
|
baseCtx context.Context
|
||||||
now func() time.Time
|
now func() time.Time
|
||||||
sessionRefreshGracePeriod time.Duration
|
sessionRefreshGracePeriod time.Duration
|
||||||
sessionRefreshCoolOffDuration time.Duration
|
sessionRefreshCoolOffDuration time.Duration
|
||||||
|
@ -83,6 +85,7 @@ func newRefreshSessionScheduler(
|
||||||
sessionID string,
|
sessionID string,
|
||||||
) *refreshSessionScheduler {
|
) *refreshSessionScheduler {
|
||||||
rss := &refreshSessionScheduler{
|
rss := &refreshSessionScheduler{
|
||||||
|
baseCtx: ctx,
|
||||||
now: now,
|
now: now,
|
||||||
sessionRefreshGracePeriod: sessionRefreshGracePeriod,
|
sessionRefreshGracePeriod: sessionRefreshGracePeriod,
|
||||||
sessionRefreshCoolOffDuration: sessionRefreshCoolOffDuration,
|
sessionRefreshCoolOffDuration: sessionRefreshCoolOffDuration,
|
||||||
|
@ -92,8 +95,7 @@ func newRefreshSessionScheduler(
|
||||||
}
|
}
|
||||||
tm := now()
|
tm := now()
|
||||||
rss.lastRefresh.Store(&tm)
|
rss.lastRefresh.Store(&tm)
|
||||||
ctx = context.WithoutCancel(ctx)
|
ctx, rss.cancel = context.WithCancel(context.WithoutCancel(rss.baseCtx))
|
||||||
ctx, rss.cancel = context.WithCancel(ctx)
|
|
||||||
go rss.run(ctx)
|
go rss.run(ctx)
|
||||||
return rss
|
return rss
|
||||||
}
|
}
|
||||||
|
@ -153,7 +155,7 @@ func (rss *refreshSessionScheduler) run(ctx context.Context) {
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
tm := rss.now()
|
tm := rss.now()
|
||||||
rss.lastRefresh.Store(&tm)
|
rss.lastRefresh.Store(&tm)
|
||||||
rss.refreshSession(ctx, rss.sessionID)
|
rss.refreshSession(rss.baseCtx, rss.sessionID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue