forked from TrueCloudLab/frostfs-s3-gw
[#XX] tree: new pilorama
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
b0e52a4b5c
commit
30ae1c469e
4 changed files with 94 additions and 0 deletions
2
go.mod
2
go.mod
|
@ -37,6 +37,8 @@ require (
|
||||||
google.golang.org/protobuf v1.33.0
|
google.golang.org/protobuf v1.33.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace git.frostfs.info/TrueCloudLab/frostfs-sdk-go => ../frostfs-sdk-go
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0 // indirect
|
git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0 // indirect
|
||||||
git.frostfs.info/TrueCloudLab/hrw v1.2.1 // indirect
|
git.frostfs.info/TrueCloudLab/hrw v1.2.1 // indirect
|
||||||
|
|
|
@ -227,6 +227,63 @@ func (w *PoolWrapper) RemoveNode(ctx context.Context, bktInfo *data.BucketInfo,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *PoolWrapper) BurnedAddNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, key string, meta map[string]string) ([]byte, error) {
|
||||||
|
resp, err := w.p.BurnedAdd(ctx, treepool.BurnedAddParams{
|
||||||
|
CID: bktInfo.CID,
|
||||||
|
TreeID: treeID,
|
||||||
|
Key: key,
|
||||||
|
Meta: meta,
|
||||||
|
BearerToken: getBearer(ctx, bktInfo),
|
||||||
|
})
|
||||||
|
return resp.GetVersion(), handleError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *PoolWrapper) BurnedGetNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, key string, version []byte) ([]*grpcService.KeyValue, error) {
|
||||||
|
resp, err := w.p.BurnedGet(ctx, treepool.BurnedGetParams{
|
||||||
|
CID: bktInfo.CID,
|
||||||
|
TreeID: treeID,
|
||||||
|
Key: key,
|
||||||
|
Version: version,
|
||||||
|
BearerToken: getBearer(ctx, bktInfo),
|
||||||
|
})
|
||||||
|
return resp.GetMeta(), handleError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *PoolWrapper) BurnedRemoveNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, key string) error {
|
||||||
|
return handleError(w.p.BurnedRemove(ctx, treepool.BurnedRemoveParams{
|
||||||
|
CID: bktInfo.CID,
|
||||||
|
TreeID: treeID,
|
||||||
|
Key: key,
|
||||||
|
BearerToken: getBearer(ctx, bktInfo),
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *PoolWrapper) BurnedListVersions(ctx context.Context, bktInfo *data.BucketInfo, treeID string, key string) ([]*grpcService.BurnedListVersionsResponse_Body_Info, error) {
|
||||||
|
resp, err := w.p.BurnedListVersions(ctx, treepool.BurnedListVersionsParams{
|
||||||
|
CID: bktInfo.CID,
|
||||||
|
TreeID: treeID,
|
||||||
|
Key: key,
|
||||||
|
BearerToken: getBearer(ctx, bktInfo),
|
||||||
|
})
|
||||||
|
|
||||||
|
return resp.GetList(), handleError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *PoolWrapper) BurnedList(ctx context.Context, bktInfo *data.BucketInfo, treeID, start string) ([]*grpcService.BurnedListResponse_Body, error) {
|
||||||
|
cli, err := w.p.BurnedList(ctx, treepool.BurnedListParams{
|
||||||
|
CID: bktInfo.CID,
|
||||||
|
TreeID: treeID,
|
||||||
|
Start: start,
|
||||||
|
BearerToken: getBearer(ctx, bktInfo),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, handleError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := cli.ReadAll()
|
||||||
|
return res, handleError(err)
|
||||||
|
}
|
||||||
|
|
||||||
func getBearer(ctx context.Context, bktInfo *data.BucketInfo) []byte {
|
func getBearer(ctx context.Context, bktInfo *data.BucketInfo) []byte {
|
||||||
if bd, err := middleware.GetBoxData(ctx); err == nil {
|
if bd, err := middleware.GetBoxData(ctx); err == nil {
|
||||||
if bd.Gate.BearerToken != nil {
|
if bd.Gate.BearerToken != nil {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/middleware"
|
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/middleware"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/internal/logs"
|
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/internal/logs"
|
||||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||||
|
grpcService "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool/tree/service"
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/user"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -37,6 +38,12 @@ type (
|
||||||
AddNodeByPath(ctx context.Context, bktInfo *data.BucketInfo, treeID string, path []string, meta map[string]string) (uint64, error)
|
AddNodeByPath(ctx context.Context, bktInfo *data.BucketInfo, treeID string, path []string, meta map[string]string) (uint64, error)
|
||||||
MoveNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, nodeID, parentID uint64, meta map[string]string) error
|
MoveNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, nodeID, parentID uint64, meta map[string]string) error
|
||||||
RemoveNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, nodeID uint64) error
|
RemoveNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, nodeID uint64) error
|
||||||
|
|
||||||
|
BurnedAddNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, key string, meta map[string]string) ([]byte, error)
|
||||||
|
BurnedGetNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, key string, version []byte) ([]*grpcService.KeyValue, error)
|
||||||
|
BurnedRemoveNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, key string) error
|
||||||
|
BurnedListVersions(ctx context.Context, bktInfo *data.BucketInfo, treeID string, key string) ([]*grpcService.BurnedListVersionsResponse_Body_Info, error)
|
||||||
|
BurnedList(ctx context.Context, bktInfo *data.BucketInfo, treeID, start string) ([]*grpcService.BurnedListResponse_Body, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
SubTreeStream interface {
|
SubTreeStream interface {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/data"
|
"git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/data"
|
||||||
|
grpcService "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/pool/tree/service"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -179,6 +180,8 @@ func (t *treeNodeMemory) listNodes(res []NodeResponse, depth uint32) []NodeRespo
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ ServiceClient = (*ServiceClientMemory)(nil)
|
||||||
|
|
||||||
func NewTreeServiceClientMemory() (*ServiceClientMemory, error) {
|
func NewTreeServiceClientMemory() (*ServiceClientMemory, error) {
|
||||||
return &ServiceClientMemory{
|
return &ServiceClientMemory{
|
||||||
containers: make(map[string]containerInfo),
|
containers: make(map[string]containerInfo),
|
||||||
|
@ -471,6 +474,31 @@ func (c *ServiceClientMemory) RemoveNode(_ context.Context, bktInfo *data.Bucket
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ServiceClientMemory) BurnedAddNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, key string, meta map[string]string) ([]byte, error) {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ServiceClientMemory) BurnedGetNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, key string, version []byte) ([]*grpcService.KeyValue, error) {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ServiceClientMemory) BurnedRemoveNode(ctx context.Context, bktInfo *data.BucketInfo, treeID string, key string) error {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ServiceClientMemory) BurnedListVersions(ctx context.Context, bktInfo *data.BucketInfo, treeID string, key string) ([]*grpcService.BurnedListVersionsResponse_Body_Info, error) {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ServiceClientMemory) BurnedList(ctx context.Context, bktInfo *data.BucketInfo, treeID, start string) ([]*grpcService.BurnedListResponse_Body, error) {
|
||||||
|
//TODO implement me
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
func metaToNodeMeta(m map[string]string) []nodeMeta {
|
func metaToNodeMeta(m map[string]string) []nodeMeta {
|
||||||
result := make([]nodeMeta, 0, len(m))
|
result := make([]nodeMeta, 0, len(m))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue