mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-19 01:28:51 +02:00
cache: support databroker option changes (#1294)
This commit is contained in:
parent
31205c0c29
commit
a1378c81f8
16 changed files with 408 additions and 179 deletions
|
@ -1,6 +1,12 @@
|
|||
package manager
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/directory"
|
||||
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultGroupRefreshInterval = 10 * time.Minute
|
||||
|
@ -10,6 +16,9 @@ var (
|
|||
)
|
||||
|
||||
type config struct {
|
||||
authenticator Authenticator
|
||||
directory directory.Provider
|
||||
dataBrokerClient databroker.DataBrokerServiceClient
|
||||
groupRefreshInterval time.Duration
|
||||
groupRefreshTimeout time.Duration
|
||||
sessionRefreshGracePeriod time.Duration
|
||||
|
@ -31,6 +40,27 @@ func newConfig(options ...Option) *config {
|
|||
// An Option customizes the configuration used for the identity manager.
|
||||
type Option func(*config)
|
||||
|
||||
// WithAuthenticator sets the authenticator in the config.
|
||||
func WithAuthenticator(authenticator Authenticator) Option {
|
||||
return func(cfg *config) {
|
||||
cfg.authenticator = authenticator
|
||||
}
|
||||
}
|
||||
|
||||
// WithDirectoryProvider sets the directory provider in the config.
|
||||
func WithDirectoryProvider(directoryProvider directory.Provider) Option {
|
||||
return func(cfg *config) {
|
||||
cfg.directory = directoryProvider
|
||||
}
|
||||
}
|
||||
|
||||
// WithDataBrokerClient sets the databroker client in the config.
|
||||
func WithDataBrokerClient(dataBrokerClient databroker.DataBrokerServiceClient) Option {
|
||||
return func(cfg *config) {
|
||||
cfg.dataBrokerClient = dataBrokerClient
|
||||
}
|
||||
}
|
||||
|
||||
// WithGroupRefreshInterval sets the group refresh interval used by the manager.
|
||||
func WithGroupRefreshInterval(interval time.Duration) Option {
|
||||
return func(cfg *config) {
|
||||
|
@ -58,3 +88,21 @@ func WithSessionRefreshCoolOffDuration(dur time.Duration) Option {
|
|||
cfg.sessionRefreshCoolOffDuration = dur
|
||||
}
|
||||
}
|
||||
|
||||
type atomicConfig struct {
|
||||
value atomic.Value
|
||||
}
|
||||
|
||||
func newAtomicConfig(cfg *config) *atomicConfig {
|
||||
ac := new(atomicConfig)
|
||||
ac.Store(cfg)
|
||||
return ac
|
||||
}
|
||||
|
||||
func (ac *atomicConfig) Load() *config {
|
||||
return ac.value.Load().(*config)
|
||||
}
|
||||
|
||||
func (ac *atomicConfig) Store(cfg *config) {
|
||||
ac.value.Store(cfg)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue