frostfs-mfa/mfa/storage.go
Alex Vanin 2413e64cab
Some checks failed
DCO action / DCO (pull_request) Failing after 21s
Vulncheck / Vulncheck (pull_request) Successful in 35s
Tests and linters / Tests with -race (pull_request) Successful in 46s
Tests and linters / Tests (pull_request) Successful in 1m13s
Tests and linters / Lint (pull_request) Successful in 1m24s
Split read and write MFA managers
Signed-off-by: Alex Vanin <a.vanin@yadro.com>
2025-03-17 15:37:17 +03:00

60 lines
2 KiB
Go

package mfa
import (
"context"
"errors"
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
)
type (
// Storage is an interface for Manager to manage FrostFS objects
// and metadata in tree service.
Storage interface {
StorageReader
// CreateObject creates new FrostFS object.
CreateObject(context.Context, PrmObjectCreate) (oid.ID, error)
// DeleteObject deletes FrostFS object.
DeleteObject(context.Context, oid.Address) error
// SetTreeNode creates or updates specified tree node the tree service and returns updated data.
SetTreeNode(ctx context.Context, cnrID cid.ID, name string, meta map[string]string) (*TreeMultiNode, error)
// DeleteTreeNode removes all specified tree nodes from the tree and returns copy of it.
DeleteTreeNode(ctx context.Context, cnrID cid.ID, name string) ([]*TreeNode, error)
}
StorageReader interface {
// GetObject returns payload of FrostFS object.
GetObject(context.Context, oid.Address) ([]byte, error)
// GetTreeNode returns data about latest and remaining versions of specified tree node.
// Must return 'ErrTreeNodeNotFound' if tree does not exist.
GetTreeNode(ctx context.Context, cnrID cid.ID, name string) (*TreeMultiNode, error)
// GetTreeNodes returns all available tree nodes with specified prefix.
GetTreeNodes(ctx context.Context, cnrID cid.ID, prefix string) ([]*TreeNode, error)
}
// TreeNode contains metadata of node in the tree service.
TreeNode struct {
Meta map[string]string
}
// TreeMultiNode contains metadata of latest and all available versions
// of node in the tree service.
TreeMultiNode struct {
Current TreeNode
Old []*TreeNode
}
// PrmObjectCreate contains parameters to create new FrostFS object.
PrmObjectCreate struct {
Container cid.ID
Owner user.ID
FilePath string
Payload []byte
}
)
var (
ErrTreeNodeNotFound = errors.New("tree node not found")
)