frostfs-mfa/mfa/storage.go

57 lines
1.9 KiB
Go
Raw Permalink Normal View History

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 {
// CreateObject creates new FrostFS object.
CreateObject(context.Context, PrmObjectCreate) (oid.ID, error)
// GetObject returns payload of FrostFS object.
GetObject(context.Context, oid.Address) ([]byte, 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)
// 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)
// 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)
// 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")
)