postgres: registry support (#3454)

This commit is contained in:
Caleb Doxsey 2022-07-13 09:14:47 -06:00 committed by GitHub
parent ca8db7b619
commit 24a9d627cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 436 additions and 36 deletions

View file

@ -4,10 +4,14 @@ import (
"time"
)
const defaultExpiry = time.Hour * 24
const (
defaultExpiry = time.Hour * 24
defaultRegistryTTL = time.Second * 30
)
type config struct {
expiry time.Duration
expiry time.Duration
registryTTL time.Duration
}
// Option customizes a Backend.
@ -20,9 +24,17 @@ func WithExpiry(expiry time.Duration) Option {
}
}
// WithRegistryTTL sets the default registry TTL.
func WithRegistryTTL(ttl time.Duration) Option {
return func(cfg *config) {
cfg.registryTTL = ttl
}
}
func getConfig(options ...Option) *config {
cfg := new(config)
WithExpiry(defaultExpiry)(cfg)
WithRegistryTTL(defaultRegistryTTL)(cfg)
for _, o := range options {
o(cfg)
}