2022-03-20 19:55:47 +00:00
|
|
|
package persistent
|
|
|
|
|
|
|
|
import (
|
2022-03-21 11:53:49 +00:00
|
|
|
"crypto/ecdsa"
|
2022-03-20 19:55:47 +00:00
|
|
|
"time"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
2022-03-20 19:55:47 +00:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
type cfg struct {
|
2022-09-28 07:41:01 +00:00
|
|
|
l *logger.Logger
|
2022-03-21 11:53:49 +00:00
|
|
|
timeout time.Duration
|
|
|
|
privateKey *ecdsa.PrivateKey
|
2022-03-20 19:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Option allows setting optional parameters of the TokenStore.
|
|
|
|
type Option func(*cfg)
|
|
|
|
|
|
|
|
func defaultCfg() *cfg {
|
|
|
|
return &cfg{
|
2024-10-21 07:22:54 +00:00
|
|
|
l: logger.NewLoggerWrapper(zap.L()),
|
2022-03-20 19:55:47 +00:00
|
|
|
timeout: 100 * time.Millisecond,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithLogger returns an option to specify
|
|
|
|
// logger.
|
2022-09-28 07:41:01 +00:00
|
|
|
func WithLogger(v *logger.Logger) Option {
|
2022-03-20 19:55:47 +00:00
|
|
|
return func(c *cfg) {
|
|
|
|
c.l = v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithTimeout returns option to specify
|
|
|
|
// database connection timeout.
|
|
|
|
func WithTimeout(v time.Duration) Option {
|
|
|
|
return func(c *cfg) {
|
|
|
|
c.timeout = v
|
|
|
|
}
|
|
|
|
}
|
2022-03-21 11:53:49 +00:00
|
|
|
|
|
|
|
// WithEncryptionKey return an option to encrypt private
|
|
|
|
// session keys using provided private key.
|
|
|
|
func WithEncryptionKey(k *ecdsa.PrivateKey) Option {
|
|
|
|
return func(c *cfg) {
|
|
|
|
c.privateKey = k
|
|
|
|
}
|
|
|
|
}
|