Evgenii Stratonikov
abd502215f
It is not a part of FSTree itself, but rather a way to solve concurrent counter update on non-linux implementations. New linux implementations is pretty simple: link fails when the file exists, unlink fails when the file doesn't exist. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
58 lines
907 B
Go
58 lines
907 B
Go
package fstree
|
|
|
|
import (
|
|
"io/fs"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
type Option func(*FSTree)
|
|
|
|
func WithDepth(d uint64) Option {
|
|
return func(f *FSTree) {
|
|
f.Depth = d
|
|
}
|
|
}
|
|
|
|
func WithDirNameLen(l int) Option {
|
|
return func(f *FSTree) {
|
|
f.DirNameLen = l
|
|
}
|
|
}
|
|
|
|
func WithPerm(p fs.FileMode) Option {
|
|
return func(f *FSTree) {
|
|
f.Permissions = p
|
|
}
|
|
}
|
|
|
|
func WithPath(p string) Option {
|
|
return func(f *FSTree) {
|
|
f.RootPath = p
|
|
}
|
|
}
|
|
|
|
func WithNoSync(noSync bool) Option {
|
|
return func(f *FSTree) {
|
|
f.noSync = noSync
|
|
}
|
|
}
|
|
|
|
func WithMetrics(m Metrics) Option {
|
|
return func(f *FSTree) {
|
|
f.metrics = m
|
|
}
|
|
}
|
|
|
|
func WithFileCounter(c FileCounter) Option {
|
|
return func(f *FSTree) {
|
|
f.fileCounter = c
|
|
}
|
|
}
|
|
|
|
func WithLogger(l *logger.Logger) Option {
|
|
return func(f *FSTree) {
|
|
f.log = &logger.Logger{Logger: l.With(zap.String("component", "FSTree"))}
|
|
}
|
|
}
|