mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-04 09:19:39 +02:00
config: allow setting directory sync interval and timeout (#1098)
Updates #567
This commit is contained in:
parent
25867501d4
commit
821f2e9000
6 changed files with 44 additions and 4 deletions
|
@ -4,12 +4,14 @@ import "time"
|
|||
|
||||
var (
|
||||
defaultGroupRefreshInterval = 10 * time.Minute
|
||||
defaultGroupRefreshTimeout = 1 * time.Minute
|
||||
defaultSessionRefreshGracePeriod = 1 * time.Minute
|
||||
defaultSessionRefreshCoolOffDuration = 10 * time.Second
|
||||
)
|
||||
|
||||
type config struct {
|
||||
groupRefreshInterval time.Duration
|
||||
groupRefreshTimeout time.Duration
|
||||
sessionRefreshGracePeriod time.Duration
|
||||
sessionRefreshCoolOffDuration time.Duration
|
||||
}
|
||||
|
@ -17,6 +19,7 @@ type config struct {
|
|||
func newConfig(options ...Option) *config {
|
||||
cfg := new(config)
|
||||
WithGroupRefreshInterval(defaultGroupRefreshInterval)(cfg)
|
||||
WithGroupRefreshTimeout(defaultGroupRefreshTimeout)(cfg)
|
||||
WithSessionRefreshGracePeriod(defaultSessionRefreshGracePeriod)(cfg)
|
||||
WithSessionRefreshCoolOffDuration(defaultSessionRefreshCoolOffDuration)(cfg)
|
||||
for _, option := range options {
|
||||
|
@ -35,6 +38,13 @@ func WithGroupRefreshInterval(interval time.Duration) Option {
|
|||
}
|
||||
}
|
||||
|
||||
// WithGroupRefreshTimeout sets the group refresh timeout used by the manager.
|
||||
func WithGroupRefreshTimeout(timeout time.Duration) Option {
|
||||
return func(cfg *config) {
|
||||
cfg.groupRefreshTimeout = timeout
|
||||
}
|
||||
}
|
||||
|
||||
// WithSessionRefreshGracePeriod sets the session refresh grace period used by the manager.
|
||||
func WithSessionRefreshGracePeriod(dur time.Duration) Option {
|
||||
return func(cfg *config) {
|
||||
|
|
|
@ -188,7 +188,7 @@ func (mgr *Manager) refreshLoop(
|
|||
func (mgr *Manager) refreshDirectoryUsers(ctx context.Context) {
|
||||
mgr.log.Info().Msg("refreshing directory users")
|
||||
|
||||
ctx, clearTimeout := context.WithTimeout(ctx, time.Minute)
|
||||
ctx, clearTimeout := context.WithTimeout(ctx, mgr.cfg.groupRefreshTimeout)
|
||||
defer clearTimeout()
|
||||
|
||||
directoryUsers, err := mgr.directory.UserGroups(ctx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue