mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-31 01:47:33 +02:00
databroker server backend config (#1127)
* config,docs: add databroker storage backend configuration * cache: allow configuring which backend storage to use Currently supported types are "memory", "redis".
This commit is contained in:
parent
c9182f757e
commit
1640151bc1
9 changed files with 99 additions and 6 deletions
|
@ -8,17 +8,22 @@ var (
|
|||
DefaultDeletePermanentlyAfter = time.Hour
|
||||
// DefaultBTreeDegree is the default number of items to store in each node of the BTree.
|
||||
DefaultBTreeDegree = 8
|
||||
// DefaultStorageType is the default storage type that Server use
|
||||
DefaultStorageType = "memory"
|
||||
)
|
||||
|
||||
type serverConfig struct {
|
||||
deletePermanentlyAfter time.Duration
|
||||
btreeDegree int
|
||||
deletePermanentlyAfter time.Duration
|
||||
btreeDegree int
|
||||
storageType string
|
||||
storageConnectionString string
|
||||
}
|
||||
|
||||
func newServerConfig(options ...ServerOption) *serverConfig {
|
||||
cfg := new(serverConfig)
|
||||
WithDeletePermanentlyAfter(DefaultDeletePermanentlyAfter)(cfg)
|
||||
WithBTreeDegree(DefaultBTreeDegree)(cfg)
|
||||
WithStorageType(DefaultStorageType)(cfg)
|
||||
for _, option := range options {
|
||||
option(cfg)
|
||||
}
|
||||
|
@ -43,3 +48,17 @@ func WithDeletePermanentlyAfter(dur time.Duration) ServerOption {
|
|||
cfg.deletePermanentlyAfter = dur
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue