frostfs-node/pkg/services/session/storage/persistent/options.go
Dmitrii Stepanov 6db46257c0
[#1437] node: Use ctx for logging
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2024-11-13 10:36:07 +03:00

49 lines
953 B
Go

package persistent
import (
"crypto/ecdsa"
"time"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
"go.uber.org/zap"
)
type cfg struct {
l *logger.Logger
timeout time.Duration
privateKey *ecdsa.PrivateKey
}
// Option allows setting optional parameters of the TokenStore.
type Option func(*cfg)
func defaultCfg() *cfg {
return &cfg{
l: logger.NewLoggerWrapper(zap.L()),
timeout: 100 * time.Millisecond,
}
}
// WithLogger returns an option to specify
// logger.
func WithLogger(v *logger.Logger) Option {
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
}
}
// 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
}
}