pomerium/internal/databroker/config.go
Kenneth Jenkins 6f6186a67d
databroker: remove unused serverConfig fields (#5314)
The databroker.serverConfig struct has a few fields which are written
to but never read.
2024-10-04 12:04:59 -07:00

52 lines
1.2 KiB
Go

package databroker
import (
"time"
)
var (
// DefaultStorageType is the default storage type that Server use
DefaultStorageType = "memory"
// DefaultRegistryTTL is the default registry time to live.
DefaultRegistryTTL = time.Minute
)
type serverConfig struct {
storageType string
storageConnectionString string
registryTTL time.Duration
}
func newServerConfig(options ...ServerOption) *serverConfig {
cfg := new(serverConfig)
WithStorageType(DefaultStorageType)(cfg)
WithRegistryTTL(DefaultRegistryTTL)(cfg)
for _, option := range options {
option(cfg)
}
return cfg
}
// A ServerOption customizes the server.
type ServerOption func(*serverConfig)
// WithRegistryTTL sets the registry time to live in the config.
func WithRegistryTTL(ttl time.Duration) ServerOption {
return func(cfg *serverConfig) {
cfg.registryTTL = ttl
}
}
// WithStorageType sets the storage type.
func WithStorageType(typ string) ServerOption {
return func(cfg *serverConfig) {
cfg.storageType = typ
}
}
// WithStorageConnectionString sets the DSN for storage.
func WithStorageConnectionString(connStr string) ServerOption {
return func(cfg *serverConfig) {
cfg.storageConnectionString = connStr
}
}