fstree

package
v0.42.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DirNameLen is how many bytes is used to group keys into directories.
	DirNameLen = 1 // in bytes
	// MaxDepth is maximum depth of nested directories.
	MaxDepth = (sha256.Size - 1) / DirNameLen
)
View Source
const Type = "fstree"

Type is fstree storage type used in logs and configuration.

Variables

This section is empty.

Functions

This section is empty.

Types

type FSTree

type FSTree struct {
	Info

	*compression.Config
	Depth      uint64
	DirNameLen int
	// contains filtered or unexported fields
}

FSTree represents an object storage as a filesystem tree.

func New

func New(opts ...Option) *FSTree

func (*FSTree) Close

func (t *FSTree) Close() error

Close implements common.Storage.

func (*FSTree) Compressor added in v0.37.0

func (t *FSTree) Compressor() *compression.Config

func (*FSTree) Delete

func (t *FSTree) Delete(ctx context.Context, prm common.DeletePrm) (common.DeleteRes, error)

Delete removes the object with the specified address from the storage.

func (*FSTree) Exists

func (t *FSTree) Exists(ctx context.Context, prm common.ExistsPrm) (common.ExistsRes, error)

Exists returns the path to the file with object contents if it exists in the storage and an error otherwise.

func (*FSTree) Get

func (t *FSTree) Get(ctx context.Context, prm common.GetPrm) (common.GetRes, error)

Get returns an object from the storage by address.

func (*FSTree) GetRange

func (t *FSTree) GetRange(ctx context.Context, prm common.GetRangePrm) (common.GetRangeRes, error)

GetRange implements common.Storage.

func (*FSTree) Init

func (t *FSTree) Init() error

Init implements common.Storage.

func (*FSTree) Iterate

func (t *FSTree) Iterate(ctx context.Context, prm common.IteratePrm) (common.IterateRes, error)

Iterate iterates over all stored objects.

func (*FSTree) ObjectsCount added in v0.39.0

func (t *FSTree) ObjectsCount(ctx context.Context) (uint64, error)

func (*FSTree) Open

func (t *FSTree) Open(mode mode.ComponentMode) error

Open implements common.Storage.

func (*FSTree) Path

func (t *FSTree) Path() string

Path implements common.Storage.

func (*FSTree) Put

func (t *FSTree) Put(ctx context.Context, prm common.PutPrm) (common.PutRes, error)

Put puts an object in the storage.

func (*FSTree) Rebuild added in v0.38.0

func (*FSTree) SetCompressor

func (t *FSTree) SetCompressor(cc *compression.Config)

SetCompressor implements common.Storage.

func (*FSTree) SetParentID added in v0.37.0

func (t *FSTree) SetParentID(parentID string)

func (*FSTree) SetReportErrorFunc

func (t *FSTree) SetReportErrorFunc(_ func(string, error))

SetReportErrorFunc implements common.Storage.

func (*FSTree) Type

func (*FSTree) Type() string

Type implements common.Storage.

type FileCounter added in v0.37.0

type FileCounter interface {
	Set(v uint64)
	Inc()
	Dec()
}

FileCounter used to count files in FSTree. The implementation must be thread-safe.

type Info

type Info struct {
	// Permission bits of the root directory.
	Permissions fs.FileMode

	// Full path to the root directory.
	RootPath string
}

Info groups the information about file storage.

type Metrics added in v0.37.0

type Metrics interface {
	SetParentID(parentID string)

	SetMode(mode mode.ComponentMode)
	Close()

	Iterate(d time.Duration, success bool)
	Delete(d time.Duration, success bool)
	Exists(d time.Duration, success bool)
	Put(d time.Duration, size int, success bool)
	Get(d time.Duration, size int, success bool)
	GetRange(d time.Duration, size int, success bool)
	ObjectsCount(d time.Duration, success bool)
}

type Option

type Option func(*FSTree)

func WithDepth

func WithDepth(d uint64) Option

func WithDirNameLen

func WithDirNameLen(l int) Option

func WithFileCounter added in v0.37.0

func WithFileCounter(c FileCounter) Option

func WithLogger added in v0.38.0

func WithLogger(l *logger.Logger) Option

func WithMetrics added in v0.37.0

func WithMetrics(m Metrics) Option

func WithNoSync

func WithNoSync(noSync bool) Option

func WithPath

func WithPath(p string) Option

func WithPerm

func WithPerm(p fs.FileMode) Option

type SimpleCounter added in v0.37.0

type SimpleCounter struct {
	// contains filtered or unexported fields
}

func NewSimpleCounter added in v0.37.0

func NewSimpleCounter() *SimpleCounter

func (*SimpleCounter) Dec added in v0.37.0

func (c *SimpleCounter) Dec()

func (*SimpleCounter) Inc added in v0.37.0

func (c *SimpleCounter) Inc()

func (*SimpleCounter) Set added in v0.37.0

func (c *SimpleCounter) Set(v uint64)

func (*SimpleCounter) Value added in v0.37.0

func (c *SimpleCounter) Value() uint64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL